我想从google云平台实例中发送带有sendgrids的电子邮件。他们有一个关于如何做到这一点的简短教程,但是它有电子邮件消息,来自谁,发送给谁,以及其他信息都在app.rb中,这不是在rails应用程序中发送消息的正常方式。
我看了sendgrid红宝石文档,他们也没有很好的信息。所有的信息在一个地方,他们没有说明哪些文件放在他们,甚至提到任何smtp设置使用。
这是我到目前为止所拥有的
development.rb
config.action_mailer.delivery_method = :smtp
# SMTP settings
config.action_mailer.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 465,
:domain => "mydomain.com",
:user_name => ENV['sendgrid_username'],
:password => ENV['sendgrid_password'],
:authentication => :plain,
:ssl => true,
:enable_starttls_auto => true
}宝石档案
gem "sendgrid-ruby"电子邮件视图在app/view中,mailer方法在app/mailer中,与普通的rails 4应用程序设置相同。
所以我想这是我的主要问题:
SendGrid::Mail,就像我在几个地方看到的那样?我刚开始在rails应用程序中发送这样的电子邮件,我真的很感激你的帮助。
发布于 2017-10-03 06:10:46
将apikey作为名称,将实际的apikey作为密码:
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 587,
domain: "yourwebsite.com",
authentication: :plain,
user_name: 'apikey',
password: Rails.application.secrets.sendgrid_api_key
}发布于 2016-07-04 18:33:52
R
# send a signup email to the user, pass in the user object that contains the
user email address
default :from => 'hello@yourdomain.com'
def send_signup_email(user)
@user = user
mail( :to => @user.email,
:subject => 'Thanks for signing up!'
)
endhttps://stackoverflow.com/questions/38184833
复制相似问题