generated from OmarMWarraich/ROR-template
-
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.
Merge pull request #28 from OmarMWarraich/27-send-emails-w-mandrill
27 send emails w mandrill
- Loading branch information
Showing
13 changed files
with
85 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class AdminMailer < ApplicationMailer | ||
default from: 'no-reply@topgeardirect.com' | ||
|
||
def new_user(user) | ||
@user = user | ||
mail(to: @user.email, subject: "New User: #{user.email}") | ||
end | ||
|
||
def mandrill_client | ||
@mandrill_client ||= MailchimpTransactional::Client.new Rails.application.credentials.dig(:smtp, :api_key) | ||
end | ||
|
||
def new_comment(comment) | ||
template_name = 'new-comment' | ||
template_content = [] | ||
message = { | ||
to: [{ email: 'omar@topgeardirect.com' }], | ||
subject: "New Comment Added: #{comment.text}", | ||
merge_vars: [ | ||
{ | ||
rcpt: 'omar@topgeardirect.com', | ||
vars: [ | ||
{ | ||
name: 'COMMENT_NAME', | ||
content: comment.text | ||
} | ||
] | ||
} | ||
] | ||
} | ||
|
||
mandrill_client.messages.send_template template_name, template_content, message | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Welcome, <%= @user.email %>!</h1> | ||
<p>Dear <%= @user.name %>,</p> | ||
<p>We are excited to have you join our community. Thank you for signing up!</p> | ||
<p>If you have any questions, feel free to reach out to us at support@topgeardirect.com.</p> | ||
<p>Best regards,</p> | ||
<p>The Team</p> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<% if user_signed_in? %> | ||
<li><%= link_to 'Sign out', destroy_user_session_path, data: { turbo_method: :delete } %></li> | ||
<% 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 +1 @@ | ||
B5s7+BYCscIXqQowLIC6T5A8XurUUO8fcLm3TPKqy7dmpjp731LbtPfRQ4qWmGQP8ltNJxsiyxSbvE1Qsr5BXz5K0PtS9hIgxtIe8H0m4eNYGlOXldSljmWgRoh9+CmS9SP51VptFlnKZXAI6IuRb6/7Ut0tG5UjqWzPR8JfJB/10xfDgeZA86MDa5vFo2BohaqzZKWpxImNiPsBgr1yFhnA4yhRqc1/uiUjrW7IKny7puI90q9f16OrMPJ4Mh2rVJYUhQc38Ey81wUGf4e5edeCYCbxFbkGghCQ68LJgElSWyv2z8Pc0X3aE3ITZkezZga7pKfz4fe+VXDsdUjb8+iFFeWpjOYXCYAjeMqQZoPLoqujShdynIRnKso8wKWZ4OfOU8PgnnZvHbSw5dXPpimEhWXAgW+G1tYc--jBT5JswiAfe1MlW9--YP2xDZrbT8C4DjHFqD3uiw== | ||
C6JJYFRlSXWEe6EZHIPAJDh4qIE0MJ1VOc+sAaq0vJTAKe3BdpADENlPPx7X9FqT8Q63/ujGblE4NPsq1LSV4fGRpgQtRcrZ+QT7kjw8GQyvkIPMSCD8u2Uh4PUzrTNYX31w105Ob0f4Ngh8U0gCIW0Xsf4+d3VaACLGav43lYU9eR4cA4AHOChQyIWpo7Yd1zagaQqBNR+NMvcFmf6DUmnW4qwLF2bh6PlMfaFV0pS8BTcEq7OIfYbm+S0p3r3lJNz+tkt79rhx+gJGhfJ0IBrii0d6G+7da4WAO9wBEyL5yJtSYFd3XPvGtYleIS0eDKHLXCitAbphUHNUh7+9DM/Tr0b0nioYcLYKzDlJDSXHwTY6cdBsJV1OLqffRULFa9PFq9SgsdXL7MJKwX0x+uTxoUeqgzlY7P4kBT8ZI0IHnxXZLAoHFJT9iqNNsEX5HSsScWLDKeqTWOu8DpPtbzqkoRQ6EL4TxtreGhrByRChQY/uobOdKKs7MzEJrb/IGzSuAy2np9Krm0e7PdV9Qk/yQnG6g0vQ7UgY/QIN0GomiWe0OjNKD/B1m+j379OpN5T77Ebva1vH3VIjenKLzcoqQyv/wkRpNQifIA==--zmXR3nXkpekjs4eT--AmeABzUYkvSaNJDHpg69Vw== |
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 |
---|---|---|
|
@@ -10,6 +10,6 @@ | |
resources :likes, only: [:create] | ||
end | ||
end | ||
|
||
root "users#index" | ||
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe AdminMailer, type: :mailer do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Preview all emails at http://localhost:3000/rails/mailers/admin_mailer | ||
class AdminMailerPreview < ActionMailer::Preview | ||
|
||
end |