From 0493e6c51e1f56af8df2313b58b448b85c348f98 Mon Sep 17 00:00:00 2001 From: grin Date: Tue, 1 Feb 2022 14:37:19 +0100 Subject: [PATCH 1/2] Update sendgrid-ruby First we need to update to the sendgrid-ruby version that supports the From address personalization. --- sendgrid-actionmailer.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sendgrid-actionmailer.gemspec b/sendgrid-actionmailer.gemspec index 778c7e2..7cc889d 100644 --- a/sendgrid-actionmailer.gemspec +++ b/sendgrid-actionmailer.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |spec| spec.require_paths = ['lib'] spec.add_dependency 'mail', '~> 2.7' - spec.add_dependency 'sendgrid-ruby', '~> 6.4' + spec.add_dependency 'sendgrid-ruby', '~> 6.6' spec.add_development_dependency 'appraisal', '~> 2.1.0' spec.add_development_dependency 'bundler' From 812b6179b293c56d82ba6cbfc3a9c4fd61a48ae2 Mon Sep 17 00:00:00 2001 From: grin Date: Tue, 1 Feb 2022 14:42:43 +0100 Subject: [PATCH 2/2] Add From address personalization --- lib/sendgrid_actionmailer.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/sendgrid_actionmailer.rb b/lib/sendgrid_actionmailer.rb index f4d6686..ac23e16 100644 --- a/lib/sendgrid_actionmailer.rb +++ b/lib/sendgrid_actionmailer.rb @@ -93,6 +93,9 @@ def setup_personalization(mail, personalization_hash) (personalization_hash['to'] || []).each do |to| personalization.add_to Email.new(email: to['email'], name: to['name']) end + if from = personalization_hash['from'] + personalization.add_from(Email.new(email: from['email'], name: from['name'])) + end (personalization_hash['cc'] || []).each do |cc| personalization.add_cc Email.new(email: cc['email'], name: cc['name']) end