更新时间:2023-10-02 23:44:22
(Rails 3)
因为我这样称呼邮件程序:
Since I call mailer like this:
CustomerMailer.customer_auto_inform(@form).deliver
在 CustomerMailer 类中,我有私有方法:
In CustomerMailer class I have private method:
def init_email_account(shop_mail)
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address => shop_mail.address,
:port => shop_mail.port,
:domain => shop_mail.domain,
:user_name => shop_mail.user_name,
:password => shop_mail.password,
:authentication => shop_mail.authentication.name,
:enable_starttls_auto => shop_mail.enable_starttls_auto
}
end
在调用发送电子邮件的 mail() 之前,您需要调用私有方法 init_email_account 以从数据库填充 smtp_settings.shop_mail 是存储有关邮件帐户设置的数据的模型.
Before calling mail() which sends email you need to call private method init_email_account to populate smtp_settings from database. shop_mail is model which stores the data about mail account settings.
HTH