Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to safely identify a DSN (delivery status notification) message

Tags:

email

pop3

dsn

I'm fetching emails from a POP3 server and I'd like to make a difference between a regular email and DSN (Delivery Status Notification) / NDR (Non-Delivery Report/Receipt) messages.

What is the best/safest way to identify those messages? Are there any particular message-headers I should be looking for?

Thanks in advance!

like image 248
Mats Avatar asked Jun 23 '10 14:06

Mats


People also ask

What is a delivery status notification?

A Delivery Status Notification (DSN), or simply a bounce, is an automated electronic mail message from a mail system informing the sender of another message about a delivery problem. The original message is said to have bounced. Errors can occur at multiple places in mail delivery.

What is a delivery status notification failure?

When you get mail from a "MAILER-DAEMON" or a "Mail Delivery Subsystem" with a subject like "Failed Delivery" or similar, it means that an email you sent was undeliverable and has been "bounced" back to you. These messages are produced automatically and usually include a reason for the delivery failure.

What is a DSN request?

A DNS query (also known as a DNS request) is a demand for information sent from a user's computer (DNS client) to a DNS server. In most cases a DNS request is sent, to ask for the IP address associated with a domain name.


1 Answers

Some mail servers implement RFC 3464. Those that do will typically generate Delivery Status Notifications with a message header Content-Type of multipart/report and three component parts (text/plain, message/delivery-status and message/rfc822). So you could detect those characteristics of the message and process accordingly. The message will generally look like this:

From: "Mail Delivery System" <[email protected]>
Subject: Delivery Status Notification (Failure) Content-Type: multipart/report; report-type=delivery-status

Content-Type: text/plain A human readable explanation of the Delivery Status Notification.

Content-Type: message/delivery-status A structured machine readable reason for the Delivery Status Notification.

Content-Type: message/rfc822 The original message.

For those mail servers that generate Delivery Status Notifications in an unstructured format, it is probably still necessary to detect their notifications by analysing the text of the From: and Subject: message headers.

like image 91
Mike Green Avatar answered Sep 27 '22 19:09

Mike Green