jandrews3 Posted October 8, 2007 Share Posted October 8, 2007 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 More sharing options...
cooldude832 Posted October 8, 2007 Share Posted October 8, 2007 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 More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 Here is the regex to check the email. <?php if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) die("Invalid Email!"); ?> Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364778 Share on other sites More sharing options...
cooldude832 Posted October 8, 2007 Share Posted October 8, 2007 I'm terrible at regex, but I do not see that validating many of the .edu urls such as schooldistrict.k12.state.us as it only validates as a Domain.(extension) Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364781 Share on other sites More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 Thats true. That regex only validates that the format is correct. Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364782 Share on other sites More sharing options...
cooldude832 Posted October 8, 2007 Share Posted October 8, 2007 Thats true. That regex only validates that the format is correct. but it is valid to have a email of [email protected] Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364784 Share on other sites More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 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 More sharing options...
cooldude832 Posted October 8, 2007 Share Posted October 8, 2007 Yeah, I guess really you just need to validate that it has a format of [0-9,a-z,A-Z,_,][@][0-9,a-z,A-Z,_,.].[0-9,a-z,A-Z,-,_] But like I said I know 0 regex Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364790 Share on other sites More sharing options...
jandrews3 Posted October 8, 2007 Author Share Posted October 8, 2007 I haven't explained it very well. What I'm looking for is not to check the format for an email address. I need to receive the bounce from an email sent out to an email address which doesn't exist. Thanks. Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364793 Share on other sites More sharing options...
cooldude832 Posted October 8, 2007 Share Posted October 8, 2007 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 More sharing options...
prime Posted October 8, 2007 Share Posted October 8, 2007 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 https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364937 Share on other sites More sharing options...
prime Posted October 8, 2007 Share Posted October 8, 2007 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 More sharing options...
jandrews3 Posted October 8, 2007 Author Share Posted October 8, 2007 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 More sharing options...
pocobueno1388 Posted October 8, 2007 Share Posted October 8, 2007 Regex isn't going to be able to detect existence. Just the format of the email. Such as it has to have the @ symbol. Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-364968 Share on other sites More sharing options...
jandrews3 Posted October 9, 2007 Author Share Posted October 9, 2007 That's kinda what I said. Can anyone help me with the problem that I have? I need to receive bouncebacks from emails sent out when the address does not exist. Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-365066 Share on other sites More sharing options...
teng84 Posted October 9, 2007 Share Posted October 9, 2007 bump interesting question i also dont know the answer That's kinda what I said. Can anyone help me with the problem that I have? I need to receive bouncebacks from emails sent out when the address does not exist. Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-365079 Share on other sites More sharing options...
john010117 Posted October 9, 2007 Share Posted October 9, 2007 As people before you have said twice, that is not possible. Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-365080 Share on other sites More sharing options...
jandrews3 Posted October 12, 2007 Author Share Posted October 12, 2007 bump Link to comment https://forums.phpfreaks.com/topic/72338-php-email-bounce/#findComment-367832 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.