3

How is it possible, using MailHost.send(), to send an email from me@example.com and if there is a bounce error it will not be sent to me@example.com but to error@example.com?

I have tried with headers like Return-Path but no success.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Jihaisse
  • 977
  • 5
  • 24
  • 1
    You cannot affect the `Return-Path:` header on the receiving end; it gets replaced by the envelope sender by the receiving MTA, so anything you put there will be overwritten. Instead, you should be setting the envelope sender (the SMTP `MAIL FROM:<>` address), which is independent from the headers. If you have `sendmail` or a compatible underneath, its `-f` option is the ticket. – tripleee Nov 13 '13 at 14:08
  • What tripleee says. The `MailHost.send()` function equivalent is to use the bounce receiving email as the `from` address, and use the `me@example.com` email only in the email itself as the `From:` header. – Martijn Pieters Nov 13 '13 at 14:10
  • Ick, except it looks as if `MailHost` explicitly replaces the `From` header if you also set the `mfrom` keyword argument in the `send()` method. – Martijn Pieters Nov 13 '13 at 14:19
  • @Martin : yes, I have tried this too... the `mfrom` replaces the `From` header... – Jihaisse Nov 13 '13 at 15:10
  • Take a look at this answer on a similar question: http://stackoverflow.com/a/1247155/722135 – Babblo Nov 26 '13 at 02:11

2 Answers2

1

I think instead you can verify if the email address exists & is valid in the first place & route the mail accordingly, I found these options which provide an API for verifying valid Email addresses

1 - Mashape
2 - Free Email Verifier
3 - Swift Email Verifer
4 - Mailgun

Hope one of those links help you out

Ram G Athreya
  • 4,892
  • 6
  • 25
  • 57
  • That will eventually works for non valid emails. But for emails with errors like full mailbox,etc... this will no work. – Jihaisse Nov 26 '13 at 08:32
0

There are 2 headers you can use:

Sender - Address of the actual sender acting on behalf of the author listed in the From: field

Error-To - Indicates where error messages should be sent. In the absence of this line, they go to the Sender

Marek
  • 7,337
  • 1
  • 22
  • 33