Module: Sisimai::Lhost::GMX
- Defined in:
- lib/sisimai/lhost/gmx.rb
Overview
Sisimai::Lhost::GMX decodes a bounce email which created by GMX gmx.net/. Methods in the module are called from only Sisimai::Message.
Constant Summary collapse
- Indicators =
Sisimai::Lhost.INDICATORS
- Boundaries =
['--- The header of the original message is following. ---'].freeze
- StartingOf =
{message: ['This message was created automatically by mail delivery software']}.freeze
Class Method Summary collapse
Class Method Details
.description ⇒ Object
80 |
# File 'lib/sisimai/lhost/gmx.rb', line 80 def description; return 'GMX: https://www.gmx.net'; end |
.inquire(mhead, mbody) ⇒ Hash, Nil
This method is abstract.
Decodes the bounce message from GMX
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sisimai/lhost/gmx.rb', line 17 def inquire(mhead, mbody) # Envelope-To: <kijitora@mail.example.com> # X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; # X-GMX-Antivirus: 0 (no virus found) # X-UI-Out-Filterresults: unknown:0; return nil if mhead['x-gmx-antispam'].nil? require 'sisimai/smtp/command' dscontents = [Sisimai::Lhost.DELIVERYSTATUS]; v = nil emailparts = Sisimai::RFC5322.part(mbody, Boundaries) bodyslices = emailparts[0].split("\n") readcursor = 0 # (Integer) Points the current cursor position recipients = 0 # (Integer) The number of 'Final-Recipient' header while e = bodyslices.shift do # Read error messages and delivery status lines from the head of the email to the previous # line of the beginning of the original message. if readcursor == 0 # Beginning of the bounce message or delivery status part readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0]) next end next if (readcursor & Indicators[:deliverystatus]) == 0 || e.empty? # This message was created automatically by mail delivery software. # # A message that you sent could not be delivered to one or more of # its recipients. This is a permanent error. The following address # failed: # # "shironeko@example.jp": # SMTP error from remote server after RCPT command: # host: mx.example.jp # 5.1.1 <shironeko@example.jp>... User Unknown v = dscontents[-1] if e.include?('@') && ( e.start_with?('"') || e.start_with?('<') ) # "shironeko@example.jp": # ---- OR ---- # <kijitora@6jo.example.co.jp> # # Reason: # delivery retry timeout exceeded if v["recipient"] != "" # There are multiple recipient addresses in the message body. dscontents << Sisimai::Lhost.DELIVERYSTATUS v = dscontents[-1] end v['recipient'] = Sisimai::Address.s3s4(e) recipients += 1 else # - SMTP error from remote server after RCPT command: # - host: mx.example.jp case when e.start_with?('SMTP error ') then v['command'] = Sisimai::SMTP::Command.find(e) when e.start_with?('host:') then v['rhost'] = e[6, e.size] else v['diagnosis'] += "#{e }" if e.empty? == false end end end return nil if recipients == 0 return {"ds" => dscontents, "rfc822" => emailparts[1]} end |