This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: full SendGrid integration with plain and HTML templates
- Loading branch information
Showing
3 changed files
with
41 additions
and
21 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 |
---|---|---|
|
@@ -12,10 +12,12 @@ def contact_email message, name, email, subject | |
to = StaticContent.load("contact", "email") | ||
|
||
mail = ::SendGridMailer.new( | ||
"OddityAvenue E-Mail Robot <[email protected]>", | ||
"[email protected]", | ||
"OddityAvenue E-Mail Robot", | ||
to, | ||
"OddityAvenue Contact - #{@subject}", | ||
@message | ||
message_plain, | ||
message_html | ||
) | ||
mail.send! if mail.valid? | ||
|
||
|
@@ -24,10 +26,13 @@ def contact_email message, name, email, subject | |
|
||
private | ||
|
||
def message_plain | ||
|
||
template = File.read('./app/views/contact_mailer/contact_email.txt.erb') | ||
puts output = ERB.new(template).result(binding) | ||
def message_html | ||
template = File.read('./app/views/contact_mailer/contact_email.html.erb') | ||
return ERB.new(template).result(binding) | ||
end | ||
|
||
def message_plain | ||
template = File.read('./app/views/contact_mailer/contact_email.txt.erb') | ||
return ERB.new(template).result(binding) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
The following message was sent from the Contact page of <%= @env %> at <%= @time %>. | ||
|
||
--------------------------------------------------------------------------------------------------- | ||
--------------------------------------------------------------------------- | ||
From : <%= @from_name %> | <%=@from_email %> | ||
Subject: <%= @subject %> | ||
--------------------------------------------------------------------------------------------------- | ||
--------------------------------------------------------------------------- | ||
|
||
<%= @message %> | ||
|
||
--------------------------------------------------------------------------------------------------- | ||
--------------------------------------------------------------------------- | ||
|
||
~ The OddityAvenue E-Mail Robot |
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