-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set a name in the
from
email address
We received a report that one of our email's was classified as spam. This might be because we were formatting the `from` email header incorrectly. RFC5322[1] suggests that emails should include a name alongside the email address in the from header. [1] https://www.rfc-editor.org/rfc/rfc5322#section-3.4
- Loading branch information
Showing
3 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationMailer < ActionMailer::Base | ||
default from: '[email protected]' | ||
default from: email_address_with_name('[email protected]', 'Jam') | ||
|
||
layout 'mailer' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ def newsletter(user) | |
|
||
mail( | ||
to: user.email, | ||
from: email_address_with_name('[email protected]', 'Chris (jam.coop)'), | ||
subject: 'jam.coop - Newsletter #2', | ||
track_opens: 'true', | ||
message_stream: 'broadcast' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class TestMailer < ApplicationMailer | ||
def application_mailer_email | ||
mail to: '[email protected]', subject: 'A test email', body: 'A test email' | ||
end | ||
end | ||
|
||
class ApplicationMailerTest < ActionMailer::TestCase | ||
test 'an application_mailer_email from has the name and email address' do | ||
mail = TestMailer.application_mailer_email | ||
assert_equal 'Jam <[email protected]>', mail.message.from_address.to_s | ||
end | ||
end |