Class: Mailpot::Smtp
- Inherits:
-
EventMachine::Protocols::SmtpServer
- Object
- EventMachine::Protocols::SmtpServer
- Mailpot::Smtp
- Defined in:
- lib/mailpot/smtp.rb
Instance Method Summary collapse
- #current_message ⇒ Object
- #get_server_domain ⇒ Object
- #get_server_greeting ⇒ Object
- #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
6 7 8 |
# File 'lib/mailpot/smtp.rb', line 6 def @current_message ||= {} end |
#get_server_domain ⇒ Object
26 27 28 |
# File 'lib/mailpot/smtp.rb', line 26 def get_server_domain Socket.gethostbyname(Socket.gethostname).first end |
#get_server_greeting ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mailpot/smtp.rb', line 15 def get_server_greeting c = Mailpot.get_config yml = YAML.load_file c[:key_file] host = get_server_domain t = DateTime.now.strftime('%a, %d %b %Y %H:%M:%S %z') = yml['banner'] = .gsub('{host}', host) = .gsub('{date}', t) return end |
#receive_data_chunk(lines) ⇒ Object
40 41 42 43 44 |
# File 'lib/mailpot/smtp.rb', line 40 def receive_data_chunk(lines) [:source] ||= "" [:source] += lines.join("\n") true end |
#receive_message ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/mailpot/smtp.rb', line 46 def port, ip = Socket.unpack_sockaddr_in(get_peername) [:ip] = ip [:port] = port Mailpot::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 https://github.com/mjezorek/Mailpot/issues" false ensure @current_message = nil end |
#receive_recipient(recipient) ⇒ Object
34 35 36 37 38 |
# File 'lib/mailpot/smtp.rb', line 34 def receive_recipient(recipient) [:recipients] ||= [] [:recipients] << recipient true end |
#receive_reset ⇒ Object
10 11 12 13 |
# File 'lib/mailpot/smtp.rb', line 10 def receive_reset @current_message = nil true end |
#receive_sender(sender) ⇒ Object
30 31 32 |
# File 'lib/mailpot/smtp.rb', line 30 def receive_sender(sender) [:sender] = sender end |