class RubyQmail::BounceHandler
Bounce Handler for Qmail Bounce messages. There are typically two types of bounces
-
Remote Bounces - When email is accepted by the remote email server, then it cannot be delivered, it
sends the message with its own error message to the Return-Path or sender address (not necessarily the same one in the From: header–although some non-RFC-compliant servers still will do this). For this processing, it is useful to enable VERP (RubyQmail does this). VERP (Variable Envelope Return Path) in Qmail appends the recipient's email address to each unique delivery, replacing the @ by the = symbol (returnpath-recipient=recipdomain@example.com).
-
Undeliverable Bounces - An email is sent back to the reuturn path with a formatted report off all undeliverable
addresses (where the remote server could not be reached or accept delivery) and the error message generated by Qmail or returned by the Remote server during the SMTP session.
Public Class Methods
# File lib/bounce.rb, line 15 def initialize(bounce_io) @bounce_io = bounce_io end
Public Instance Methods
Parses a Qmail bounce message as IO object, then calls block with |address, message| for each bounced address
# File lib/bounce.rb, line 20 def parse(&block) address=nil mesage=nil bounces=0 @bounce_io.each do |line| break if line =~ /^--- Below this line is a copy of the message\./ if line =~ /^<(\S+)>:/ address = $1 message='' bounces += 1 elsif bounces==0 next #elsif line ~! /\S/ # empty # yield address, message elsif line =~ /Remote host said: (.+)/ yield address, $1 #message += line end end bounces end