-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1274 from internetee/idn-code-formatting
added prepend action to format foreign symbols to punicode
- Loading branch information
Showing
8 changed files
with
67 additions
and
15 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
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
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
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
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
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,4 +1,37 @@ | ||
class ApplicationMailer < ActionMailer::Base | ||
before_action :add_smtputf8_header | ||
after_action :convert_email_to_punycode | ||
|
||
default from: Rails.application.config.customization['email_from_address'] | ||
layout 'mailer' | ||
|
||
private | ||
|
||
def add_smtputf8_header | ||
headers['SMTPUTF8'] = 'true' | ||
end | ||
|
||
def convert_email_to_punycode | ||
convert_recipient_to_punycode | ||
convert_carbon_copy_to_punycode | ||
convert_blind_carbon_copy_to_punycode | ||
end | ||
|
||
def convert_recipient_to_punycode | ||
mail.to = Array(mail.to).map { |email| convert_domain_to_punycode(email) } | ||
end | ||
|
||
def convert_carbon_copy_to_punycode | ||
mail.cc = Array(mail.cc).map { |email| convert_domain_to_punycode(email) } | ||
end | ||
|
||
def convert_blind_carbon_copy_to_punycode | ||
mail.bcc = Array(mail.bcc).map { |email| convert_domain_to_punycode(email) } | ||
end | ||
|
||
def convert_domain_to_punycode(email) | ||
local, domain = email.split('@') | ||
domain = SimpleIDN.to_ascii(domain) | ||
"#{local}@#{domain}" | ||
end | ||
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
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