[英]Can I use ActionMailer when using a 3rd party library to send emails via http?
I am using a 3rd party library that sends emails using a HTTP based API. 我正在使用第三方库,它使用基于HTTP的API发送电子邮件。
Is it still possible for me to use ActionMailer to construct the emails and then somehow use ActionMailer to generate the resulting HTML/text for the email which I could then pass to my http email lib to send? 我是否仍然可以使用ActionMailer构建电子邮件,然后以某种方式使用ActionMailer为电子邮件生成生成的HTML /文本,然后我可以将其传递给我的http电子邮件库发送?
Absolutely. 绝对。 In fact, this is standard practice. 实际上,这是标准做法。 You don't need to do anything special, just configure ActionMailer to use the 3rd party of your choice. 您无需执行任何特殊操作,只需将ActionMailer配置为使用您选择的第三方。 Here's an example from my production.rb
file, using Mailgun: 这是我的production.rb
文件中的一个示例,使用Mailgun:
Rails.application.configure do
# other config stuff goes here...
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: 'your_domain.com' }
config.action_mailer.smtp_settings = {
authentication: :plain,
address: 'smtp.mailgun.org',
port: 587,
domain: Rails.application.secrets[:mailgun_domain],
user_name: Rails.application.secrets[:mailgun_username],
password: Rails.application.secrets[:mailgun_password]
}
end
Then in your Rails.application.secrets
file, you put the info specific to your account. 然后在您的Rails.application.secrets
文件中,您将特定于您帐户的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.