Class: MailCatcher::Smtp
- Inherits:
-
EventMachine::Protocols::SmtpServer
- Object
- EventMachine::Protocols::SmtpServer
- MailCatcher::Smtp
- Defined in:
- lib/mail_catcher/smtp.rb
Instance Method Summary collapse
- #current_message ⇒ Object
-
#process_mail_from(sender) ⇒ Object
We override EM’s mail from processing to allow multiple mail-from commands per [RFC 2821](tools.ietf.org/html/rfc2821#section-4.1.1.2).
- #receive_data_chunk(lines) ⇒ Object
- #receive_message ⇒ Object
- #receive_recipient(recipient) ⇒ Object
- #receive_reset ⇒ Object
- #receive_sender(sender) ⇒ Object
Instance Method Details
#current_message ⇒ Object
15 16 17 |
# File 'lib/mail_catcher/smtp.rb', line 15 def @current_message ||= {} end |
#process_mail_from(sender) ⇒ Object
We override EM’s mail from processing to allow multiple mail-from commands per [RFC 2821](tools.ietf.org/html/rfc2821#section-4.1.1.2)
6 7 8 9 10 11 12 13 |
# File 'lib/mail_catcher/smtp.rb', line 6 def process_mail_from sender if @state.include? :mail_from @state -= [:mail_from, :rcpt, :data] receive_reset end super end |
#receive_data_chunk(lines) ⇒ Object
35 36 37 38 39 |
# File 'lib/mail_catcher/smtp.rb', line 35 def receive_data_chunk(lines) [:source] ||= "" [:source] << lines.join("\n") true end |
#receive_message ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mail_catcher/smtp.rb', line 41 def MailCatcher::Mail. puts "==> SMTP: Received message from '#{[:sender]}' (#{[:source].length} bytes)" true rescue puts "*** Error receiving message: #{.inspect}" puts " Exception: #{$!}" puts " Backtrace:" $!.backtrace.each do |line| puts " #{line}" end puts " Please submit this as an issue at http://github.com/sj26/mailcatcher/issues" false ensure @current_message = nil end |
#receive_recipient(recipient) ⇒ Object
29 30 31 32 33 |
# File 'lib/mail_catcher/smtp.rb', line 29 def receive_recipient(recipient) [:recipients] ||= [] [:recipients] << recipient true end |
#receive_reset ⇒ Object
19 20 21 22 |
# File 'lib/mail_catcher/smtp.rb', line 19 def receive_reset @current_message = nil true end |
#receive_sender(sender) ⇒ Object
24 25 26 27 |
# File 'lib/mail_catcher/smtp.rb', line 24 def receive_sender(sender) [:sender] = sender true end |