This is the method inside ApplicationMailer
这是ApplicationMailer中的方法
class CancelTrip < ApplicationMailer
default from: 'xyz@gmail.com'
def cancel_trip
@recvr= "ssdd@gmail.com"
mail(to: @recvr, subject: 'Your trip has been cancelled as per your request' )
end
end
And the environmental variables as follows:
而环境变量如下:
SMTP_ADDRESS: 'smtp.gmail.com'
SMTP_PORT: 587
SMTP_DOMAIN: 'localhost:3000'
SMTP_USERNAME: 'xyz@gmail.com'
SMTP_PASSWORD: 'gggh2354'
And I am call the mailer method in my controller as follows:
我在控制器中调用邮件程序方法如下:
def cancel
xxxxx
CancelTrip.cancel_trip.deliver_now
end
developement.rb has following
developement.rb有以下内容
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default_url_options = {host: 'localhost', port:3000}
config.action_mailer.perform_deliveries = true
Log shows the email being sent. But I dont see any email in inbox. My rails version is 4.2.6.
日志显示正在发送的电子邮件。但我在收件箱中看不到任何电子邮件。我的rails版本是4.2.6。
5 个解决方案
#1
1
Add following smtp setting on config/application.rb
file:
在config / application.rb文件中添加以下smtp设置:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "xxxxxxxxx@gmail.com",
:password => "xxxxxxxx",
:authentication => "plain",
:enable_starttls_auto => true
}
#2
0
Check in junk mail... I had this problem a little while back
检查垃圾邮件...我回来时遇到了这个问题
#3
0
use letter opener in development for be sure your actionmailer delivered your mail. after that you can finding deliver error to gmail or other.
在开发中使用开信刀,以确保您的动作制作者发送了您的邮件。之后你可以找到传递错误给gmail或其他。
#4
0
Make sure that your ApplicationMailer
is inheriting from ActionMailer::Base.
确保您的ApplicationMailer继承自ActionMailer :: Base。
class ApplicationMailer < ActionMailer::Base
default from: 'from@exmaple.com'
layout 'mailer'
end
#5
0
One possibility may be your firewall not allows to send email. Try connect different network.
一种可能是您的防火墙不允许发送电子邮件。尝试连接不同的网络。
#1
1
Add following smtp setting on config/application.rb
file:
在config / application.rb文件中添加以下smtp设置:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "xxxxxxxxx@gmail.com",
:password => "xxxxxxxx",
:authentication => "plain",
:enable_starttls_auto => true
}
#2
0
Check in junk mail... I had this problem a little while back
检查垃圾邮件...我回来时遇到了这个问题
#3
0
use letter opener in development for be sure your actionmailer delivered your mail. after that you can finding deliver error to gmail or other.
在开发中使用开信刀,以确保您的动作制作者发送了您的邮件。之后你可以找到传递错误给gmail或其他。
#4
0
Make sure that your ApplicationMailer
is inheriting from ActionMailer::Base.
确保您的ApplicationMailer继承自ActionMailer :: Base。
class ApplicationMailer < ActionMailer::Base
default from: 'from@exmaple.com'
layout 'mailer'
end
#5
0
One possibility may be your firewall not allows to send email. Try connect different network.
一种可能是您的防火墙不允许发送电子邮件。尝试连接不同的网络。