Created
February 1, 2010 00:00
-
-
Save assaf/291325 to your computer and use it in GitHub Desktop.
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
class ActionMailer::Base | |
# We're using the SendGrid SMTP API to send emails to a large distribution | |
# list. During testing, we want to validate that each recipient received a | |
# copy of the email. Do that by looking for emails sent to a distribution | |
# list and creating multiple copies, one for each recipient. | |
def perform_delivery_test(mail) | |
mail.ready_to_send # All duplicates must have same message id | |
smtpapi = JSON.parse(mail["X-SMTPAPI"].to_s) if mail["X-SMTPAPI"] | |
if smtpapi && smtpapi["to"] | |
mail.delete "X-SMTPAPI" | |
smtpapi["to"].each do |to| | |
clone = TMail::Mail.parse(mail.to_s) | |
clone["Delivered-To"] = to | |
perform_delivery_test clone | |
end | |
else | |
deliveries << mail | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment