我希望你能借给我个忙!
我曾经在当地发展,但我在国外,我使用CLOUD9有一些项目合作。 目前,它让我很难与行动梅勒。
我的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
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
</head>
<body>
<h1>Welcome to example.com, <%= @user.email %></h1>
<p>
You have successfully signed up to example.com,
your username is: <%= @user.email %>.<br>
</p>
<p>
To login to the site, just follow this link: <%= @url %>.
</p>
<p>Thanks for joining and have a great day!</p>
</body>
</html>
安慰
u = User.first
GunMailer.welcome_email(u).deliver
我已经建立了与费加罗的环境变量,并evrything似乎是正确的。但邮件永远不会发送! 我听说C9射门被一些端口(587是其中之一),我试过用2587,2525(推荐其他海报),但它不工作!