Module: Mail::CheckDeliveryParams
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/mail/check_delivery_params.rb
Overview
:nodoc:
Class Method Summary collapse
- .check(mail) ⇒ Object
- .check_addr(addr_name, addr) ⇒ Object
- .check_from(addr) ⇒ Object
- .check_message(message) ⇒ Object
- .check_to(addrs) ⇒ Object
- .validate_smtp_addr(addr) ⇒ Object
Class Method Details
.check(mail) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/mail/check_delivery_params.rb', line 10 def check(mail) envelope = Mail::SmtpEnvelope.new(mail) [ envelope.from, envelope.to, envelope. ] end |
.check_addr(addr_name, addr) ⇒ Object
32 33 34 35 |
# File 'lib/mail/check_delivery_params.rb', line 32 def check_addr(addr_name, addr) mail = Mail.new(from: '[email protected]', to: '[email protected]') Mail::SmtpEnvelope.new(mail).send(:validate_addr, addr_name, addr) end |
.check_from(addr) ⇒ Object
18 19 20 21 |
# File 'lib/mail/check_delivery_params.rb', line 18 def check_from(addr) mail = Mail.new(from: '[email protected]', to: '[email protected]') Mail::SmtpEnvelope.new(mail).send(:validate_addr, 'From', addr) end |
.check_message(message) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/mail/check_delivery_params.rb', line 53 def () = .encoded if .respond_to?(:encoded) if Utilities.blank?() raise ArgumentError, 'An encoded message is required to send an email' end end |
.check_to(addrs) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/mail/check_delivery_params.rb', line 24 def check_to(addrs) mail = Mail.new(from: '[email protected]', to: '[email protected]') Array(addrs).map do |addr| Mail::SmtpEnvelope.new(mail).send(:validate_addr, 'To', addr) end end |
.validate_smtp_addr(addr) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mail/check_delivery_params.rb', line 38 def validate_smtp_addr(addr) if addr if addr.bytesize > 2048 yield 'may not exceed 2kB' end if /[\r\n]/ =~ addr yield 'may not contain CR or LF line breaks' end end addr end |