tags:

views:

312

answers:

4

Hi friends,

Is it possible to retrieve the SMTP response of a mail. For example, I am sending a mail to non existing email id. Surely our server will send us a mailer daemon failure mail to our mail id. I need to capture that failure mail.

How its possible? please explain me. Some time we may enter more than one non existing email id, so i have to retrieve all the failure mail alone for every corresponding emails

Please guide me!

Thanks in advance,

Praveen J

+1  A: 

I am not sure if I am getting your question right. If you send an email to any non existent address say [email protected] from your address [email protected], the mail server at gmail.com replies to the mail server at yourhost.com with failure message and reason, with your delivery address and you receive the fialure mail automatically. you don't have to do anything extra in this.

If you are talking about seeing mail headers, then it depends on which client you are using. For instace, if you are using MS outlook, you can right-click on the message and click options and then see internet headers section to get mail headers. If you are using some web based mail then i am sure there will some option to view detailed mail headers.

Chandan .
exactly, your right!. Actually i my application i need to retrieve the failure mail of the corresponding send mails.
praveenjayapal
A: 

The bounced messages are going to return to a mailbox. You should be able to configure that mailbox by properly setting the headers on the messages you send out. You would then need to monitor that mailbox, or have that mailbox deliver the messages to your program.

I would suggest you consider using VERP for all messages you send out. It will make it much easier for you to identify which email address a particular bounce belongs too. To do this you would need control of your mail server though. It takes some work configuring things.

To answer the question with more detail you need to tell us how your are sending messages, what type of mail server you are running, and how much control you have over the mail server.

Zoredache
SMTP server, HTML type. whether is it possible to retrieve the failure mail of the corresponding send mail in my application.
praveenjayapal
+1  A: 

I think I understood your question correctly now. As I understand, you are writing an application to send mail. And in your application, whenever you send a mail, you also want verify that if mail was delivered and also if it was not delivered then you want to get hold of the failure message in your application. Is that how you mean?

Well, if that is how you mean, then I think it is impossible to track the mail status with your apllication code. For instance if you are using java sendMail in your apllication you can only ensure that the send happened from your code successfully(without any send exceptions like java.net.SocketException or javax.mail.MessagingException). But, you can never ensure if the mail really reached the recepient. i.e. you can never track in your application if the mail was rejected due to wrong recepient address or any other error like illegal attachment at receipient mail server or errors like blocked sender id etc.

That is because any such error condition will be communicated by the receipient mail server to the sending mail server the information of which is present in the sent mail's header.

Does that answer your question? (Or did I understand your question correctly? ;-))

Chandan .
yes perfectly u got it. Please let me know if "track of mail status" is possible! Any way thanks for your explanation
praveenjayapal
seemingly none. i doubt if there exist any API's for this as far as java sendMail is concerned. i don't know if there is a mechanism for fetching a certain mail from the mail server's message queue using plain SMTP requests. And even if there is as the failure response would eb flushed from ....
Chandan .
....the mail server queue as soon as it is forwarded to the mail client, you can't intercept and read the message through your code as you can't guess the turnaround time of failure response in order to check for any such messages.
Chandan .
A: 

On Unix, you can use "procmail" for this. Procmail is a service which can intercept your mails and process them following rules.

If you can access your mail my IMAP, I suggest to look at the Python module imaplib.

Aaron Digulla