...

View Full Version : Return-Path: <> Error



Jon T
06-07-2004, 09:00 PM
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?

MrShed
06-08-2004, 09:36 AM
Can you not just pass it in the header? Just guessing a bit here, but can you not do something like this:


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

MrShed
06-08-2004, 09:37 AM
Sorry it would be "Return-Path: " etc etc...missed the hyphen

Jon T
06-10-2004, 10:12 PM
The messages have been sending, but nothing goes though or bounces. How would one set the SMTP server and port number?



<?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!

firepages
06-11-2004, 05:23 AM
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 )



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

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

Jon T
06-11-2004, 06:50 AM
This is nice, but my main concern is the Return-Path, and SMTP. So I assume it would look like this.



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

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


Correct?

firepages
06-11-2004, 07:42 AM
$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() (http://www.php.net/ini_set) at runtime to set them .


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

Jon T
06-11-2004, 07:44 AM
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.

Jon T
06-14-2004, 10:53 PM
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.



<?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;
?>


:confused:

carl_mcdade
06-15-2004, 07:51 AM
What SMTP server are you using and what are the settings. Could it be the server will not send without a return path?

Jon T
06-15-2004, 01:21 PM
Actually, we are needing the return-path for bounced messages. The mail server, SmarterMail uses this field to return the message to the sender.

ReadMe.txt
06-16-2004, 01:32 AM
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.

Jon T
06-16-2004, 04:21 AM
This...


<?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...


From:Jon T Cc:me@mydomain Return-Path:me@mydomain

Email Headers are this...


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.

maghiel
06-16-2004, 11:18 AM
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:



ini_set("SMTP","mail.myserver.nl");
ini_set("smtp_port","25");
ini_set("sendmail_from","me@myserver.nl");


et voila :)

Jon T
06-16-2004, 04:20 PM
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:



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.

Jon T
06-16-2004, 04:28 PM
maghiel, Yo freakie deakie dog! that worked!

Using the main smtp server instead of the second one fixed it.

:thumbsup:

ReadMe.txt
06-16-2004, 09:27 PM
The <> may be the hint here, try wrapping the email addresses in the header ith < and >

Jon T
06-16-2004, 11:55 PM
The problem is that the Qmail server that is set in the PHP.ini is stripping the Return-Path field in the headers. The ini_set will allow me to use the local mail server before the Qmail server and keep the Return-Path header until the message bounces.

:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum