Skip to content

Commit

Permalink
Adding AWS SES Support To Emails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shounaks committed Dec 13, 2024
1 parent 5fd2a38 commit 56dc312
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ gem 'shellwords'

# PDF reader for validating PDF file submissions
gem 'pdf-reader'

#panopto auth
gem 'aws-sdk-ses'
29 changes: 29 additions & 0 deletions app/mailers/aws_ses_integrated_mailer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'aws-sdk-ses' # v2: require 'aws-sdk'

def use_ses_for_mail(sender, recipient, subject, htmlbody, textbody, encoding){
ses = Aws::SES::Client.new(region: '')
begin
ses.send_email(
destination: {to_addresses: [recipient]}, message: {
body: {
html: {
charset: encoding,
data: htmlbody
},
text: {
charset: encoding,
data: textbody
}
},
subject: {
charset: encoding,
data: subject
}
}, source: sender
)

puts "Email sent to #{recipient}"
rescue Aws::SES::Errors::ServiceError => e
puts "Email not sent. Error message: #{e}"
end
}

0 comments on commit 56dc312

Please sign in to comment.