Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Return-Path: <> Error

    When I send an email, I can set the to and from. But my mail server requires the return-path to be filled for the Auto-Responder to work. Is there a way to fill the Return-Path: <> with a value other then listed in the PHP.ini file?

  • #2
    New Coder
    Join Date
    Jun 2004
    Location
    Newcastle, England
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Can you not just pass it in the header? Just guessing a bit here, but can you not do something like this:

    PHP Code:
    mail($toemail$subject$message"From:".$fromemail"Return Path: ".$returnpath); 

  • #3
    New Coder
    Join Date
    Jun 2004
    Location
    Newcastle, England
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry it would be "Return-Path: " etc etc...missed the hyphen

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    The messages have been sending, but nothing goes though or bounces. How would one set the SMTP server and port number?

    Code:
    <?php
    	$tomail = "user@dom.com";
    	$message = "This is my message";
    	$fromemail = "sender@dom.com";
    	$returnpath = "sender@dom.com";
    	if(mail("To: ".$toemail, "Body: ".$message, "From: ".$fromemail, "Return-Path: ".$returnpath)){
    		print "YA! It was sent";
    	}
    	else{
    		print "<p>And you Thought this **** would actually Run!</p>";
    	}
    	exit;
    ?>
    Thank You!

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    check out the manual at http://www.php.net/mail (download the chm its priceless)

    the only place you need to stick SMTP flags (To: , From: etc ) is in the 4th (headers) argument ..

    mail ( 'blah@blah' , 'Subject' , 'Message Body' , $headers ) ;

    where headers may say (they are optional) for example ( straight from the manual )

    PHP Code:
    <?
    $subject
    ='My Subject';
    $body='MyMessage';
    /* additional headers */ 
    $headers "From: Birthday Reminder <birthday@example.com>\r\n"
    $headers .= "Cc: [email]birthdayarchive@example.com[/email]\r\n"
    $headers .= "Bcc: [email]birthdaycheck@example.com[/email]\r\n"

    mail 'blah@blah' $subject $body $headers ) ;
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #6
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is nice, but my main concern is the Return-Path, and SMTP. So I assume it would look like this.

    PHP Code:
    <? 
    $subject
    ='My Subject'
    $body='MyMessage'
    /* additional headers */  
    $headers "From: Birthday Reminder <birthday@example.com>\r\n";  
    $headers .= "Cc: [email]birthdayarchive@example.com[/email]\r\n";  
    $headers .= "Bcc: [email]birthdaycheck@example.com[/email]\r\n";  
    $headers .= "Return-Path: [email]birthday@example.com[/email]\r\n";
    $headers .= "SMTP: mail.exampledomain.com\r\n";

    mail 'blah@blah' $subject $body $headers ) ; 
    ?>
    Correct?

  • #7
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    $headers .= "SMTP: mail.exampledomain.com\r\n"; is not required & does nothing the SMTP server needs to be on the local machine (else you con not use mail()) , you can not specifiy a remote webserver in that way , if you do not have a mailserver on your machine then you have to use fsockopen() & friends to connect directly to the SMTP server , search on google for `PHP SMTP classes or functions` (or similar) for more info on talking directly to a remote mailserver

    if you have a local mailserver your php.ini should have the SMTP path and port , if not (and they should be) you can use ini_set() at runtime to set them .


    , also note that [ email ][ \email ] tags in my post were added by the forum & need to go!
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #8
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, thanks for hte information, I was trying to connect to a different smtp server then what the INI is listing, so I will do some reading on this.

  • #9
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Wow, none of this is working at all... Downloaded the chm file, very nice, tried about a half a dozen other ideas, still nothing... I just need to fill the "Return-Path" with the senders email while on a windows server, with no email set in the php.ini.

    Code:
    <?PHP
    	$subject='My Subject';
    	$body='Put Your Text Message Here.';
    
    	/* additional headers */
    	$headers = "From: Jon T <from@mydomain.com>\r\n";
    	$headers .= "Cc: to@theirdomain.com\r\n";
    	$headers .= "Return-Path: from@mydomain.com\r\n";
    	$headers .= "SMTP: mail.mydomain.com\r\n";
    
    	if(mail ( 'to@theirdomain.com' , $subject , $body , $headers )){
    		echo "Message was sent!";
    	}
    	else{
    		echo "Message was not sent!";
    	}
    	exit;
    ?>
    Last edited by Jon T; 06-14-2004 at 10:56 PM.

  • #10
    Regular Coder
    Join Date
    May 2004
    Location
    sweden
    Posts
    236
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What SMTP server are you using and what are the settings. Could it be the server will not send without a return path?
    Carl McDade
    _____________
    Hiveminds Magazine
    for web publisher and community builders
    eRuby Tutorials

  • #11
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, we are needing the return-path for bounced messages. The mail server, SmarterMail uses this field to return the message to the sender.

  • #12
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    a little bit of debug info might help to determin the problem, have PHP output all the parameters just prior to the mail() call and post them here. have the mail be sent to an address you can check and then also post the message you receive complete with all the headers.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #13
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs down

    This...
    Code:
    <?PHP
    	$subject='My Subject';
    	$body='Put Your Text Message Here.';
    
    	/* additional headers */
    	$headers = "From:Jon T <me@mydomain.com>\r\n";
    	$headers .= "Cc:me@mydomain.com\r\n";
    	$headers .= "Return-Path:me@mydomain.com\r\n";
    
    	if(mail ('me@mydomain', $subject, $body, $headers )){
    		echo $headers;
    	}
    	else{
    		echo $headers;
    	}
    	exit;
    ?>
    Prints This...
    Code:
    From:Jon T Cc:me@mydomain Return-Path:me@mydomain
    Email Headers are this...
    Code:
    Return-Path: <> Tue, 15 Jun 2004 20:15:14
    Received: from smtp3.domain.com [XXX.XXX.XXX.XXX] by mail1.domain.com  with SMTP;
       Tue, 15 Jun 2004 20:15:14 -0700
    Received: (qmail 12376 invoked from network); 16 Jun 2004 03:16:04 -0000
    Received: from unknown (HELO WEBB25) (XXX.XXX.XXX.XXX)
      by smtp3.mydomain.com with SMTP; 16 Jun 2004 03:16:04 -0000
    smtp3 is my Qmail Server, mail1, is my mail server, webb25 is my web server. Looks like the headers are getting stripped some place.

  • #14
    Regular Coder
    Join Date
    Jun 2004
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I red correctly you just want to set the smtp-server and port in php.ini?

    easy, you can set the php.ini settings from within your code:

    PHP Code:
    ini_set("SMTP","mail.myserver.nl"); 
    ini_set("smtp_port","25"); 
    ini_set("sendmail_from","me@myserver.nl"); 
    et voila

  • #15
    Regular Coder
    Join Date
    Dec 2002
    Location
    Phoenix, Arizona, USA
    Posts
    148
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by maghiel
    If I red correctly you just want to set the smtp-server and port in php.ini?

    easy, you can set the php.ini settings from within your code:

    PHP Code:
    ini_set("SMTP","mail.myserver.nl"); 
    ini_set("smtp_port","25"); 
    ini_set("sendmail_from","me@myserver.nl"); 
    et voila
    This is actually the second thing I wanted to do and was looking at last night, so thank you very much on this! What I am really wanting to is to set the Return-Path, but it looks like the QMail server is ripping this value out, I was thinking maybe if I hit the primary SMTP Server before hitting the Secondary SMTP server it would help.

    My INI is set to hit smtp1.domain.com first which is the main smtp relay server. I wanted to try and set my own smtp mail.mydomain.com in the code to see if this helped.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •