# Before:
class BillingMailer < ApplicationMailer
require 'mail'
address = Mail::Address.new "billing@#{Setting.panel_domain}"
address.display_name = "#{Setting.title} Billing"
default template_path: 'mailers/billing',
from: address.format
# After:
class BillingMailer < ApplicationMailer
default template_path: 'mailers/billing',
from_name: "#{Setting.title} Billing",
from_email: "billing@#{Setting.panel_domain}"
Sometimes you wish to show the name of the person instead of just their email address when they receive the email. The trick to doing that is to format the email address in the format "Full Name <email>".
class AdminMailer < ActionMailer::Base
default from: 'te...@nowaker.net'
def welcome_email(user)
@user = user
email_with_name = %("#{@user.name}" <#{@user.email}>) # EXACT COPY-PASTE FROM DOCS
mail(to: email_with_name, subject: 'Welcome to My Awesome Site')
end
end
class TestUser
attr_accessor :email
attr_accessor :name
end
user = TestUser.new
user.name = 'Nowak" <spam+INJECTED+CO...@nowaker.net>, "original'
user.email = 'spam+O...@nowaker.net'
email = AdminMailer.welcome_email(user)
# => #<Mail::Message:71665960, Multipart: false, Headers: <From: te...@nowaker.net>, <To: "Nowak" <spam+INJECTED+CO...@nowaker.net>, "original" <spam+O...@nowaker.net>>, <Subject: Welcome to My Awesome Site>, <Mime-Version: 1.0>, <Content-Type: text/html>>

--
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-core/Fyjf-o7KTtQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-co...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.