简体   繁体   English

使用第三方库通过http发送电子邮件时,我可以使用ActionMailer吗?

[英]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.

相关问题 我可以在开发环境中使用 ActionMailer 发送和接收电子邮件吗? - Can i send and receive emails using ActionMailer in development env.? Rails 6:通过 Webpacker 包含 3rd Party Yarn 库 - Rails 6: Include 3rd Party Yarn Library via Webpacker Ruby on Rails:在开发过程中,如何将请求发送到使用HTTPS的第三方API? - Ruby on Rails: While in development, how can I send requests to 3rd party API that uses HTTPS? 如何配置ActionMailer以在开发模式下有条件地发送电子邮件? - How can I configure ActionMailer to conditionally send emails in development mode? 我该如何插入<script type='text/javascript' src=''> tag on a 3rd party webpage using rails? - How can I insert a <script type='text/javascript' src=''> tag on a 3rd party webpage using rails? 如何存根或模拟第三方库 - How to stub or mock 3rd party library 如何使用ActionMailer发送HTML电子邮件? - How do I send html emails with ActionMailer? 使用第三方邮件发送Rails TDD? - Rails TDD using a 3rd party mailer? 使用rails发送gcm推送通知来创建第三方应用服务器 - creating a 3rd party application server using rails to send gcm push notifications 在Rails中处理异步第三方HTTP请求 - Handling asynchronous 3rd party http requests in rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM