Open a terminal window
- CD to a directory where you would like to store your simple use Web API application
- To create the rails application, run the command:
rails new basic-paubox-web-api - Run command:
cd basic-paubox-web-api - Run command:
rails generate mailer UserMailer - Open the application in a text editor of your choice and open the app/mailers/user_mailer.rb file
-
In the file, paste the following, be sure to use the same email address that we have given the customer:
class UserMailer < ApplicationMailer
default from: 'CUSTOMER_USERNAME@api.paubox.com'def welcome_email(email)
mail(to: email, subject: 'Hello')
end
end -
Save and close the file
-
Run command:
touch app/views/user_mailer/hello_email.html.erb - Open the hello_email.html.erb file in your text editor
- Copy and paste the following:
<h1>Hello</h1><p>You have successfully received a Paubox encrypted email</p> - Save and close the file
- Open the file config/application.rb
-
below this line`config.active_record.raise_in_transactional_callbacks = true`, paste the following, be sure to use the username and password that was given to the customer:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "api.paubox.com",
:port => 587,
:user_name => "CUSTOMER_USERNAME@api.paubox.com",
:password => "GIVEN_PASSWORD",
:enable_starttls_auto => true,
} - Save and close the file
- In the terminal window, run the command:
rails console - In the rails console, run the command:
UserMailer.hello_email('email_address_to_send_test_email_to').deliver_now - Go to the inbox for the email_address_to_send_test_email_to and look for the Hello email.
- When you receive it, the email should look like below and it should be encrypted by Paubox
Comments
0 comments
Please sign in to leave a comment.