Tuesday, March 23, 2010 Rails 3 Action Mailer Example Create Rails app rails my_app cd my_app Create mailer rails g mailer notifier Create Support Resource rails g resource support Remove Support's migration (we don't use database) rm db/migrate/20100323085113_create_posts.rb Sending email via Gmail # config/application.rb ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_set
Railscasts - Action Mailer in Rails 3ãè¦ã¦ã ä½ãæ¹ rails g mailer hoge ããã¾ã§ã¨ã¯éã app/mailers é ä¸ã«ã²ãªå½¢ãä½ããã 使ãæ¹ mail(:to => email, :subject => "subject", :from => "[email protected]") ä¸è¨ã®ããã«ããã°ããã©ã«ãã®å¤ã宣è¨ã§ãã default :from => email éãæ¹ã¯ããã¾ã§ã®ããã«ãã¡ã½ããåã®åã«deliver_ããã£ã¤ããæ¹å¼ã§ã¯ãªããªã£ããä¸è¨ã®ãããªæãã§éä¿¡ãã UserMailer.registration_confirmation(@user).deliver æ·»ä»ã¡ã¼ã«ãã¤ããã«ã¯attachementsã¡ã½ããã使ã attachments["rails.png"] = file view gene
Ruby on Rails Guides: Action Mailer Basicsãèªãã§ã®èªåç¨ã¡ã¢ã§ãã Mailerãä½ã rails generate mailer UserMailer Maileræ¦è¦ defaultã§mailã¡ã½ããã®ããã©ã«ãå¼æ°ãæå®ã§ãã mailã¡ã½ããã§mailãéã controllerã¨åãããã«ãããã§å®ç¾©ããã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¯viewã§ã使ãã class UserMailer < ActionMailer::Base default :from => "[email protected]" def welcome_email(user) @user = user @url = "http://example.com/login" mail(:to => user.email, :subject => "Welcome to
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}