ç°å¢
- Rails 5
ãããã¨
ãããªããã¨
- ActiveJobã«ããéåæå¦ç
Googleã¢ã«ã¦ã³ã
ã©ãããã»ãã¥ãªãã£çã«å³ãããªã£ãã®ããGoogleã¢ã«ã¦ã³ãã®ï¼æ®µéèªè¨¼ã®è¨å®ããã¦ããªãã¨ä»äººã«ã¡ã¼ã«ãéä¿¡ã§ããªããªã£ãããã
ããããè¨å®ãã
次ã«ã¢ããªãã¹ã¯ã¼ãã¨ããã®ãè¨å®ããã
ã¢ããªãã¹ã¯ã¼ãã£ã¦ã®ã¯æ®æ®µã®ãã°ã¤ã³ã«ä½¿ããã¹ã¯ã¼ãã¨ã¯éã£ã¦çæãããï¼åº¦ãã表示ã§ããªãã£ã¦ãã¤
ããããä½ã£ã¦ã¡ã¢
railsã®è¨å®
config/application.rbã«ä»¥ä¸ã追å
class Application < Rails::Application config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: "smtp.gmail.com", port: 587, user_name: '*****@gmail.com', password: 'ãã£ãä½ã£ãã¢ããªãã¹ã¯ã¼ã', } end
ã¡ã¼ã©ã¼ãã¸ã§ãã¬ã¼ã¿ã¼ã§ä½æ ããã§ã¯NoticeMailerã£ã¦ååã«ãããããããMailerããªãä»ã§ã大ä¸å¤«
~/rails/scrape $rails g mailer NoticeMailer
create app/mailers/notice_mailer.rb
invoke erb
create app/views/notice_mailer
app/mailers/notice_mailer.rbã以ä¸ã®ããã«
class NoticeMailer < ApplicationMailer default to: "*****@gmail.com" def alert() mail(subject: "失æãã¾ãã") end end
app/views/notice_mailer/alert.text.erbãä½ã£ã¦é©å½ã«æåãå ¥ãã¦ããï¼æåã¯
ã§éä¿¡
NoticeMailer.alert().deliver_now