๐งTransactional Emails
Last updated
Last updated
Visit the Postmark Website: Go to Postmark's official website.
Sign Up: Click on the โSign Upโ button typically located at the top right of the homepage.
Fill in Your Details: Enter your email address, password, and any other required information to create a new account.
Confirm Your Email: Check your inbox for a confirmation email from Postmark. Click the link in the email to verify your account.
Set Up Your Account: Log in to your newly created account and complete the setup process as prompted. This may include providing additional information about your business or intended use of the service. โ๏ธ Make sure to mention that you are using postmark for transactional emails (welcome emails, payment confirmation etc...) and in NO case for promotional emails.
Once your account is set up, you need to verify and add your domain:
Navigate to the Domains Section: In your Postmark dashboard, find the "Domains" section.
Add Your Domain: Click the โAdd Domainโ button and follow the instructions to verify your domain. This usually involves adding DNS records provided by Postmark to your domain's DNS settings in Namecheap or other domain providers.
After your domain is set up, configure your application:
Add Your Domain Name: Open your application.rb
file and add your domain name as necessary.
For Development, we don't want to use our Postmark credits. So we will use the gem Letter Opener instead, which is already installed by default in LR. Open development.rb
and add this line:
The Gem will open a new .html tab with the view of the email. Use it for styling ๐จ
Set Your API Key: Create a .env
file in the root of your project (if it doesn't already exist) and add your Postmark API key. You can find your API key in the Postmark dashboard under the โAPI Tokensโ section.
Create a welcome mailer to trigger after a user creates an account:
Change the sender's default email:
This will create a few files under the mailers and views folder. Go to user_mailer.rb
and write the following code:
Then create the mailer view:
In user.rb we want to create a callback method to automatically send the welcome email as soon as the user is created.
Et voila! Your users will receive transactional emails, so make sure to watch out for your free credits, you should have 100 emails per month for free, enough to get your first MVP users ๐