是否可以从当前用户电子邮件发送电子邮件?
Is it possible to send emails from the current user email?
我正在为一家公司开发内部运营经理,他们需要向他们的客户发送自动电子邮件,但电子邮件必须由负责该特定客户的公司运营商的电子邮件地址发送.
所以基本上,我需要配置我的邮件程序以处理 N 封不同的电子邮件(我也可以访问他们的电子邮件密码)。
config.action_mailer.smtp_settings = {
:address => 'smtp.office365.com',
:port => '587',
:authentication => :login,
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:domain => 'interworldfreight.com',
:enable_starttls_auto => true
}
我看到可以通过这种方式将电子邮件地址发送到邮件程序配置:
def new_mail
mail from: "example@example.com", to: "user@example.com"
end
但是密码呢?仅通过 rails 是否可行,或者我是否应该考虑其他工具,如 MailGun?
非常感谢您花时间阅读本文。
显然您可以发送一个包含用户名、主机和密码的 delivery_options 对象。
class FclExwOperationMailer < ApplicationMailer
def info_request (representative, shipper)
@representative = representative
@shipper = shipper
delivery_options = { user_name: representative.smtp_user,
password: representative.smtp_password,
address: representative.smtp_host }
mail(to: shipper.email,
subject: "Please see the Terms and Conditions attached",
delivery_method_options: delivery_options)
end
end
我正在为一家公司开发内部运营经理,他们需要向他们的客户发送自动电子邮件,但电子邮件必须由负责该特定客户的公司运营商的电子邮件地址发送.
所以基本上,我需要配置我的邮件程序以处理 N 封不同的电子邮件(我也可以访问他们的电子邮件密码)。
config.action_mailer.smtp_settings = {
:address => 'smtp.office365.com',
:port => '587',
:authentication => :login,
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:domain => 'interworldfreight.com',
:enable_starttls_auto => true
}
我看到可以通过这种方式将电子邮件地址发送到邮件程序配置:
def new_mail
mail from: "example@example.com", to: "user@example.com"
end
但是密码呢?仅通过 rails 是否可行,或者我是否应该考虑其他工具,如 MailGun?
非常感谢您花时间阅读本文。
显然您可以发送一个包含用户名、主机和密码的 delivery_options 对象。
class FclExwOperationMailer < ApplicationMailer
def info_request (representative, shipper)
@representative = representative
@shipper = shipper
delivery_options = { user_name: representative.smtp_user,
password: representative.smtp_password,
address: representative.smtp_host }
mail(to: shipper.email,
subject: "Please see the Terms and Conditions attached",
delivery_method_options: delivery_options)
end
end