Cloud9和ActionMailer / Mailgun?
我希望你能帮帮忙!
我曾经在本地开发,但我在国外,我正在使用Cloud9来处理一些项目。 目前,使用Action Mailer让我很难过。
我的ActionMailer初始化程序:
ActionMailer::Base.smtp_settings = { port: '2525', address: 'smtp.mailgun.org', user_name: ENV['MAILGUN_SMTP_LOGIN'], password: ENV['MAILGUN_SMTP_PASSWORD'], domain: 'app07ad98bdda3b4c469a24228512cffe5c.mailgun.org', authentication: :plain, content_type: 'text/html' } ActionMailer::Base.delivery_method = :smtp
邮寄/ gun_mailer.rb
class GunMailer < ActionMailer::Base default from: "from@example.com" def welcome_email(user) @user = user @url = 'http://example.com/login' mail(to: @user.email, subject: 'Welcome to My Awesome Site') end end
视图/ gun_mailer / welcome_email.erb
Welcome to example.com,
You have successfully signed up to example.com, your username is: .
To login to the site, just follow this link: .
Thanks for joining and have a great day!
安慰
u = User.first GunMailer.welcome_email(u).deliver
我用figaro设置了环境变量,并且evrything似乎是正确的……但邮件永远不会发送! 我听说C9有一些端口被封锁(587就是其中之一),我已经尝试过2587,2525(和其他推荐的海报一样),但它不起作用!
首先,我将确保使用Rails控制台在您的mail.rb中实际设置以下变量:
ENV['MAILGUN_SMTP_LOGIN'] ENV['MAILGUN_SMTP_PASSWORD']
其次,您应该通过执行以下操作来validation端口是否未被阻止:
$ telnet smtp.mailgun.org 2525 $ telnet smtp.mailgun.org 587
注意:如果您看到类似于以下内容的内容,则不会阻止该端口:
Trying 104.130.177.23... Connected to smtp.mailgun.org. Escape character is '^]'. 220 ak47 ESMTP ready
如果以上端口之一未被阻止,那么我将在此处停止,更新邮件初始化程序以使用未阻止的端口,并重新检查您的代码。 否则,我会继续阅读。
第三,如果你确定两个端口都被阻止了,那么你需要使用HTTP API,我会在这里阅读文档:
https://documentation.mailgun.com/api-sending.html#sending
要么
使用Heroku.com或DigitalOcean.com等其他托管公司。
好吧,我希望上面的信息可以帮助您解决问题。