Method: Net::SMTP#send_message
- Defined in:
- lib/net/smtp.rb
#send_message(msgstr, from_addr, *to_addrs) ⇒ Object Also known as: send_mail, sendmail
Sends msgstr as a message. Single CR (“r”) and LF (“n”) found in the msgstr, are converted into the CR LF pair. You cannot send a binary message with this method. msgstr should include both the message headers and body.
from_addr is a String or Net::SMTP::Address representing the source mail address.
to_addr is a String or Net::SMTP::Address or Array of them, representing the destination mail address or addresses.
Example
Net::SMTP.start('smtp.example.com') do |smtp|
smtp. msgstr,
'[email protected]',
['[email protected]', '[email protected]']
end
Net::SMTP.start('smtp.example.com') do |smtp|
smtp. msgstr,
Net::SMTP::Address.new('[email protected]', size: 12345),
Net::SMTP::Address.new('[email protected]', notify: :success)
end
Errors
This method may raise:
-
Net::SMTPServerBusy
-
Net::SMTPSyntaxError
-
Net::SMTPFatalError
-
Net::SMTPUnknownError
-
Net::ReadTimeout
-
IOError
794 795 796 797 798 799 800 |
# File 'lib/net/smtp.rb', line 794 def (msgstr, from_addr, *to_addrs) to_addrs.flatten! raise IOError, 'closed session' unless @socket from_addr = Address.new(from_addr, 'SMTPUTF8') if any_require_smtputf8(to_addrs) && capable?('SMTPUTF8') mailfrom from_addr rcptto_list(to_addrs) {data msgstr} end |