Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bounce Back Undeliverable Emails

Status
Not open for further replies.

smashing

Programmer
Joined
Oct 15, 2002
Messages
170
Location
US
In a PHP script that sends email confirmation to customers.....
$subjectcust ="Your Reservation Information\r\n";
$mailheaderscust ="From: Reservations <info@vamoosebus.com>\r\n";
$mailheaderscust .="Reply-To:Reservations<info@vamoosebus.com>\r\n";

//send the mail
mail($tocust, $subjectcust, $confirm, $mailheaderscust);


If the email address I'm sending to isn't valid for any reason shouldn't it bounce back to me? This isn't happening and I wonder why not?
 
Not necessarily.

If, for example, you're running PHP on a unix-like OS which has its own mail server, and that server thinks it's the mail exchanger for that domain, and if it does not have your mailbox defined on it, then it will dump the mail.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Some site's dont respond with bad email address they just remain quiet. If a site does returns hackers can work out id the address is valid, it also uses up bandwidth
 
Well it'll return an email address if sent via a mail program (ie Outlook, Entourage etc) but not if sent via a PHP script.
I had a feeling then, that these issues are built-in in such mail programs. But I was told that it truly is server-side which again makes me think I could improve something in my script.
 
It could be a missing or malformed SMTP header.

Examine the headers of a bounced message which made its way back to Outlook. Are there headers there that you could adapt to your script's email?

Have you taken a look at PHPMailer?



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
The additional header found in bounced messages to outlook is:
Return-path:<whatever@whatever.com>

I've tried preceding this to the other mailheaders in my script but to no avail.
Also, I'm reluctent to use PHPMailer or to copy something as to that nature because taking a look into that program I've found this for example:

if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "Message has been sent";



I do not want the user to have to wait for the email to go through succesfully in order to see his confirmation right away. Rather I'd display something right away, and then if the additional email confirmation to them does not go through (and this may take a while) that email should be bounced.
Any ideas?
 
SMTP is non-deterministic. If your user's mail server is down, your mail server may attempt redelivery for days before finally giving up and reporting a bounce.

If you want deterministic feedback, you're probably going to have to use PHP's socket functions to attempt to send the email directly from your script (as opposed to indirectly through a mail server).



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
How 'ya doin Sleipnir?
I checked out PHP's socket functions as you reccomend and see that they all have that warning about them being "EXPERIMENTAL. The behaviour of this function, the name of this function, and anything else documented about this function may change without notice in a future release of PHP. Use this function at your own risk."
I don't feel comfortable using it then at this time.
I have a gut feeling that the problem may still lie in my header information which now read as thus:

$mailheaders ="Return-path: <info@vamoosebus.com>\r\n";
$mailheaders .="From:Vamoosebus Reservations<info@vamoosebus.com>\r\n";
$mailheaders .="Reply-To:Vamoosebus Reservations<info@vamoosebus.com>\r\n";

The reason I think so is that emails are usually bounced back almost immediatly when using Outlook but NEVER using my script.
 
Taking a look in my php.ini file (in which my host does not let me make any changes) I see that under sendmail_from the value is: no value.
Which may explain why when looking in the headers of emails received I see this as the very first line
Return-path: <www@hostsecuresite.com>(...the secure setting of the server and nothing I specified in my custom script.)
I've usually seen the value of sendmail_from listed as me@localhost.
I'll admit that I've tried setting the value of sendmail_from myself using ini_set() but saw no noticeable difference....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top