Jump to content

Php Email Bounce


jandrews3

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: [email protected]\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 "[email protected]".

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

"Return-Path: [email protected]\r\n",

&

"Return-Receipt-To: [email protected]\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
https://forums.phpfreaks.com/topic/72338-php-email-bounce/
Share on other sites

when you say in valid you mean if the if statement returns false?  This will not occur even if an email is invalid.  Infact you have no knowledge of if it reaches a destination (if its outside your server),  maybe you can try validating the email address with regex first

Link to comment
https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364774
Share on other sites

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

 

but it is valid to have a email of

[email protected]

 

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
https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364789
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
https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364841
Share on other sites

here's a simple mime mail script

 

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

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>



</body>
</html>
";

// 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";*/

mail($to,$subject,$message,$headers);
?>

 

otherwise you could just use a simple mail()

Link to comment
https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364941
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
https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364959
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.