2
多個收件人我有這樣的代碼:發送電子郵件使用net/SMTP
require "net/smtp"
MAIL_SERVER = "xxx.ad.xxx.net"
def lib_sending_report(email_hash)
# define message body
message = <<"MESSAGE_END"
From: <#{email_hash[:sender]}>
To: <#{email_hash[:recipients]}>
MIME-Version: 1.0
Content-type: text/html
Subject: #{email_hash[:subject]}
<p>Hi All,</p>
<p>We've just executed a round of load test.</p>
<p>Regards</p>
MESSAGE_END
Net::SMTP.start(MAIL_SERVER) do |smtp|
smtp.send_message message, email_hash[:sender], email_hash[:recipients]
end
end
test = ""
lib_sending_report({:sender => "[email protected]",
:recipients => "[email protected]",
:subject => "Load.Test.Report.of.#{test}"})
當我改變:recipients => "[email protected]"
到:recipients => "[email protected];[email protected]"
,它給了我這個錯誤:
501 5.5.4 Invalid Address (Net::SMTPSyntaxError)
我可以成功發送電子郵件時:recipients => "[email protected]"
只有一個收件人。
我在哪裏錯了?看來我使用的分隔符(分號)是錯誤的。
我嘗試使用,而不是分號逗號,但沒有奏效
非常感謝。它的工作原理〜我更注重分號並忘記send_message的To參數 – mCY