我正在mail
使用以下非常简单的代码发送带有 gem 的电子邮件。当我发送电子邮件时,smtp_account.user_name
andsmtp_account.from
可能是 eg support@thebestcompany.com
。这会导致收件人看到他收到了一封电子邮件support
(你知道,在他的收件箱中,他可以查看他最近 x 封电子邮件的概览)。我如何指定这一点,以便收件人看到更有趣的东西,例如The Best Company
?
require 'mail'
class SmtpMails
def self.send_mails(smtp_account, to, subject, text)
options = {
:address => smtp_account.address,
:port => smtp_account.port,
:domain => smtp_account.domain,
:user_name => smtp_account.user_name,
:password => smtp_account.password,
:authentication => smtp_account.authentication,
:enable_starttls_auto => smtp_account.enable_starttls_auto
}
Mail.defaults do
elivery_method :smtp, options
end
mail = Mail.deliver do
to to
from smtp_account.from
subject subject
end
end
end