3

I want to get response from server with server status (eg. 200, 500) that says if message was delivered. How to do that?

>> s = smtplib.SMTP('...')
>> resp = s.sendmail('me@me.com', 'exist@email.com', 'message')
>> print resp
{}
>> resp = s.sendmail('me@me.com', 'does-not-exist-email@email.com', 'message')
>> print resp
{}
>> resp = s.sendmail('me@me.com', 'does-not-exist-domain@email000.com', 'message')
>> print resp
{}

o_O

Thanks.

User
  • 1,978
  • 5
  • 26
  • 47

2 Answers2

5

You can't. SMTP does not support that behavior.

pancakes
  • 682
  • 5
  • 8
4

This is normal behavior of sendmail in case of successful sending. You can check this both in doc and smtp lib source. Empty dictionary as a response means that server accepted and sent message to each of recipients.

Regarding the status of delivery. SMPT protocol is simply unable to guaranty at this stage that message will be successfully delivered to the recipient. This means that first server may accept the message and push it forward, but one of the next mail-hop servers may simply drop it (for some reasons, of course, and first server will probably be informed about these reasons, but there is no possibility to inform you about all this stuff).

As they say about emailing - 'It is easy to send message, but it is much harder to get it delivered'.

Roman Bodnarchuk
  • 29,461
  • 12
  • 59
  • 75
  • Yup, I've tried with set_debuglevel(1) and saw that server accepts all addresses. But when I'm calling getreply() method on the server object after an email was sent, server is hanging up o_O – User Dec 15 '11 at 12:28