Jump to content

Php Email Bounce


Recommended Posts

I am using a very simple script for emailing:

$to = $row['email'];

$subject = "Bounce Test";

$body = "This is a php email bounce test.";

$headers = "From: jandrews@jamesa3.com\r\n" .

"X-Mailer: php".


if (mail($to, $subject, $body, $headers)) echo("<p>Sent.</p>");}

else {echo("<p>Message delivery failed...</p>");}


What I need is when any of the email addresses are not valid, I want it to bounce back to my email address "jandrews@jamesa3.com".

I have looked for examples online, but none of them seem to work. I tried adding:

"Return-Path: detect-bounce@yourdomain.com\r\n",


"Return-Receipt-To: bounce@yourdomain.com\r\n"


... but the ampersand gave an error as did the comma. I then used a period instead of a comma and removed the ampersand ... still no positive results. I tried a variety of different configurations using this code with small changes each time.


This is a very important project for me. I would be very greatful for any help!!! Thank you!



Link to comment
Share on other sites

Thats true. That regex only validates that the format is correct.


but it is valid to have a email of



I guess in this case that regex doesn't do much good. I use it on my site for registration, but the users also must validate their email...so it works fine in my case.



Link to comment
Share on other sites

I explained this in my first post, once it leaves your domain it can't be touched, easily, generally because most servers don't want to share that data.  Yes your aol mail knows when it fails, but as for how it is done that is the question.  I think they must pay for the right to recieve that error of failured to recieve.

Link to comment
Share on other sites

if I may.


you could use the pop3 imap funtions to read a pop3 account, and react to any error messages that pop3 or imap server receives, but you'd have to have that email address in the headers of the mail funtion that you used to send the email whether via mail() or mime mail

Link to comment
Share on other sites

here's a simple mime mail script


$to = "enter the addres to send here";
$subject = "subject line here";

$message = "
<title>HTML email</title>


// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

// More headers
$headers .= 'From: <email from which you want the mail to come from here>' . "\r\n";
/*$headers .= 'Cc: any cc emails you want to send here seperated by comma's' . "\r\n";
$headers .= 'Bcc: any bcc mails you want to send to here seperated by comma's' . "\r\n";*/



otherwise you could just use a simple mail()

Link to comment
Share on other sites

What I understand is that you're telling me that the regex won't work because it simply verifies syntax, not existence. And, Prime, I'm afraid I didn't understand what you were telling me. I'm fairly new at some of this more complex stuff. I don't know what pop3 imap functions are. Could you explain?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.