使用外部SMTP在Heroku上发送电子邮件

使用外部SMTP在Heroku上发送电子邮件

本文介绍了使用外部SMTP在Heroku上发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Heroku的我的Rails应用程序发送电子邮件。
由于Heroku不支持SMTP,我使用外部SMTP服务器。



config / environments / production.rb有以下几行。

  ActionMailer :: Base.delivery_method =:smtp 
ActionMailer :: Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => myusername,
:password => password,
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}

当我从heroku run console发送邮件时,它工作正常。但它不会从网站发送电子邮件。奇怪的是,heroku日志 - 尾巴显示发送邮件...。其实这封电子邮件没有寄出。



有人对这个问题有任何想法吗?



p>

Sam Kong

解决方案

您是否在config / enviornment.rb

  ActionMailer :: Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => myusername,
:password => password,
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}


I want to send emails from my rails application on Heroku.As Heroku doesn't support SMTP, I use external SMTP server.

config/environments/production.rb has the following lines.

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :address => 'mydomain.com',
  :port => 587,
  :user_name => "myusername",
  :password => "password",
  :authentication => :plain,
  :enable_starttls_auto => true,
  :openssl_verify_mode => 'none'
}

When I send an email from "heroku run console", it works fine. But it doesn't send email from the website. Strangely, "heroku logs --tail" shows "Sent mail to ...". Actually the email is not delivered.

Does anyone have any idea about this issue?

Thanks.

Sam Kong

解决方案

Have you tried this in config/enviornment.rb

ActionMailer::Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => "myusername",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}

这篇关于使用外部SMTP在Heroku上发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 14:16