I am piping all e-mails through a PHP script that checks the To address against a database of valid addresses. If it exists, the rest of the script handles it. However, if it does not exist, how can I bounce the e-mail, the same way the server would if I didn't have the script? Thanks!
-
Where are email messages coming from in the first place? – Dai Mar 04 '13 at 01:27
-
a bounce is just an email with the appropriate headers (usually) added - also most mail servers will do this for you, much better approach than building it in php – Mar 04 '13 at 01:41
-
Dai: e-mails from anywhere. Dagon: The e-mail addresses are only used to receive, not send. They are not setup as e-mail accounts in cPanel. – givemesnacks Mar 04 '13 at 01:50
-
you can create receive only email addresses a few ways – Mar 04 '13 at 01:57
-
I'm interested in doing this as well... I pipe all emails into a PHP script that scrubs for valid recipients. It's easy enough to ignore junk email. But I'd like to "return to sender" with the most effective header/body combination for getting me removed from their lists. That's more or less what you're asking, right? – designosis Mar 08 '13 at 18:39
2 Answers
The mails are recieved through smtp protocol, in your case also i assume that there is some service running on port 25 which would listen to request for mail from external domains.
There are different ways to bounce the message
->bounce at smtp level itself, as in when u get the recipient list, check f or the id existance and if does-not exists give a 4xx response. The bouncemai l would then be generated by the senders domain automatically.
-> if you have accepted the mail from the domain say gmail.com then u will have to make a new connection to gmail with your bouncemessage, this is same as sending a new mail from your server to gmail.com.

- 1,416
- 1
- 16
- 42
Turns out this was very easy to solve: Simply echo something in the PHP script (for example, "This account does not exist.") and the mailer daemon generates a bounce-back e-mail with this output included.

- 336
- 4
- 12