GCE + Rails + SendGrid でメール送信
- GCE = Google Compute Engine
SendGridで
Setup guide > SMTP Relay と進んで、API keyを生成します(このキーがパスワードになります)。
Railsで
enviroment.rb または 各環境の設定ファイルにsmtpの設定を追記します。default_url_optionsの設定も忘れずに。ここでコツなのはportに「2525(465や587ではなく)」を指定するところです。ドキュメントにあるとおり、GCEでは主要なメール送信用のポートが閉じられています。
config/enviroments/staging.rb
config.action_mailer.default_url_options = {
:host => 'yourdomain.com', :protocol => 'https'}
ActionMailer::Base.smtp_settings = {
:user_name => 'apikey',
:password => 'yourpassword',
:domain => 'yourdomain.com',
:address => 'smtp.sendgrid.net',
:port => 2525,
:authentication => :plain,
:enable_starttls_auto => true
}
参考URL
https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html
https://cloud.google.com/compute/docs/tutorials/sending-mail/using-sendgrid
Author And Source
この問題について(GCE + Rails + SendGrid でメール送信), 我々は、より多くの情報をここで見つけました https://qiita.com/lumbermill/items/0394fc6cfe6788bbe90f著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .