class RubyQmail::BounceHandler

Bounce Handler for Qmail Bounce messages. There are typically two types of bounces

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).

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

new(bounce_io) click to toggle source
# File lib/bounce.rb, line 15
def initialize(bounce_io)
  @bounce_io = bounce_io
end

Public Instance Methods

parse() { |address, $1| ... } click to toggle source

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