วันพุธที่ 25 มกราคม พ.ศ. 2555

Delivery Status Notification: How does it work?

sendmail 8.7 has no hook to request a DSN from the commandline, it can be only done in an ESMTP dialogue. This is quite reasonable, since options (as introduced in sendmail 8.8), are barely flexible enough to allow for something like this (slightly modified from the RFC):

R: 220 Pure-Heart.ORG SMTP server here
S: EHLO Pure-Heart.ORG
R: 250-Pure-Heart.ORG
R: 250-DSN
R: 250 SIZE
S: MAIL FROM: RET=HDRS ENVID=QQ314159
R: 250 sender ok
S: RCPT TO: NOTIFY=SUCCESS,DELAY ORCPT=rfc822;Bob@Big-Bucks.COM
R: 250 recipient ok
S: RCPT TO: NOTIFY=FAILURE ORCPT=rfc822;Carol@Ivory.EDU
R: 250 recipient ok
S: RCPT TO: NOTIFY=SUCCESS,FAILURE ORCPT=rfc822;Dana@Ivory.EDU
R: 250 recipient ok
S: RCPT TO: NOTIFY=NEVER
R: 250 recipient ok

Let's look at some of the additional keywords: In the MAIL command you can specify what to return (RET=). This only applies to an e-mail that couldn't be delivered. For each RCPT you specify what kind of DSN you want (NOTIFY=):

SUCCESS when the e-mail has successfully been delivered.
FAILURE when the e-mail couldn't be delivered.
DELAY when the e-mail delivery has been delayed.
NEVER you want no DSN at all.