· 1 min read
Screencast: HTML Emails mit Rails verschicken
Downloads in verschiedenen Formaten:
Resourcen:
terminal
[bash] rails new mailit cd mailit rails g mailer newsletter_mailer weekly bundle rails c [/bash]
Gemfile
[ruby] gem ‘roadie’
# or
gem ‘hpricot’ gem ‘premailer-rails3’ [/ruby]
app/mailers/newsletter_mailer.rb
[ruby] def weekly(email) mail to: email, subject: “RailsCasts Weekly” end [/ruby]
config/environments/development.rb
[ruby] config.action_mailer.default_url_options = { host: “railscasts.com” } config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: “smtp.gmail.com”, port: 587, domain: “railscasts.com”, authentication: “plain”, enable_starttls_auto: true, user_name: ENV[“GMAIL_USERNAME”], password: ENV[“GMAIL_PASSWORD”] } [/ruby]
rails console
[ruby] NewsletterMailer.weekly(“foo@example.com”).deliver [/ruby]