Mailtrap and Testing

There are some problems you often encounter in Testing:

  • You must test a system that has the function to send email to registered users. But these users are real users of the system. I guarantee, if you keep that test, your gods will receive junk mail like mushroom after rain, so annoying and violating security.
  • Or less serious is that you have to send an email to a list of registered mail addresses, have your account, have someone else's account, how to confirm if not directly open all mailboxes that out?

You probably don't want that. So how to confirm the mail test without causing trouble to other users?

Mailtrap is a great solution for you.

7bb7dcd77c901e27a31248f5035535c48bc4a791

Mailtrap provides a fake SMTP server (fake SMTP server) for the development team. Used to test emails sent from pre-production environments and test environments with real data, while avoiding the risk of sending email to real customers of the test system. It also allows you to automatically forward mail to your inbox regularly, share with your team and more!

Basically, you only need to register an account using Mailtrap, setting to synchronize with the project code of the app to test, and send all emails that need to be tested by the pre-production environment to email addresses that need to receive mail. notice ^^. All such emails will be sent to fake SMTP Mailtrap server instead of sent to the email you specified.

aecbe27380c72393ec80768d948d243ef54807e1

After that, you can view and check your emails in Mailtrap's friendly interface.

If your project is small, just need to test 1 user at a time and the number of emails to test is not too large, you can use Mailtrap for free. But for large projects, it is necessary to test with multiple users, corresponding to many different inboxes, in addition to the number of emails to test greater than 50 mail / inbox, the cost you need to pay to use Mailtrap will fluctuate in the range of from $ 120 to $ 300 per year depending on your needs.

Screen Shot 2016-09-29 at 3.18.51 PM

I. Basic features of Mailtrap:

12b7781736c4aebe05939a275d27d44c8f2f7d0e

  1. Never happens to spam mail real customers because of development team negligence
  2. Analyze email for spam and blacklist
  3. HTML test for support by the common email clients
  4. Security default (HTTPS & TLS)
  5. Install quickly and easily using the config code
  6. Improve RESTful & POP3 API autotests
  7. Automatically forward emails to people who need them
  8. Arrange Email test in special mailbox
  9. Share inboxes with your team

II. How to get started with Mailtrap

1. Register an account:

You can easily register for a Mailtrap account with your existing email accounts, you can also use existing Google or Github accounts.

3f72e394e25771178db9e3400b665b9df9d684fd

Here I use my Gmail account.

eb4e76dbde79ac36bc815606df69777ba427b477

After successful registration and login, you can see Demo inbox in Mailtrap interface.

If you use a premium account, you can create more inboxes, each inbox will be corresponding to a different mailing system.

cebef74bfdb7f22e871138fb6b8e2a6e3b64bd3d

2. Configure Mailtrap:

Next, we will set up Mailtrap in your project development environment.

Open inbox, click on the "SMTP Settings" tab, you will see for each Mailtrap Inbox there will be information about the private SMTP server:

8b518676502ed7855e910d4140843a4b471b219d

You can reset this information whenever you want.

Mailtrap provides a series of examples for configuration, which configuration options will depend on your project type. When there are multiple Inboxes, you can configure each Inbox with a project of different types.

62c37a4c2e1d77e5d0cea128b441784ec6fa6a91

For example: Configuring with Laravel project

5721979dd08a012972b25863fa8856589f7d49fb

For simplicity, we take the example of a small Laravel app that resets an account's password:

a61922b7e34ce19680a3d46f2f32eeee38824329 In the soucecode project of this app, open the environment configuration file and enter Mailtrap's SMTP server configuration parameters into the corresponding items.

7630852046c9dd06dd7c9ea99c7c8eef1a3cab06

Save the changes, and see the results!

67aa37bc8059798ed7dd2acdd26fce8b8aa90fd2

After sending a password reset request to any email, normally the password reset email will be sent to the specified email address.

But when using Mailtrap, this email address will not receive the mail reset password notification, instead Mailtrap server will "catch" this mail and save in the inbox has been set. And we can check the content to reset the mail mail password in the inbox of Mailtrap.

f0bfe1321408b4c2aed1246776957c8954cde11d

In the body of the email you receive, there are a lot of tabs you can choose from, which allow you to check the content of the email received in many different formats:

By default, the email view is in HTML format. There is also a view in HTML source format:

0b8db7f31e74e7425486041b561307ec62fc76b9

Or Text, Raw:

af837cda2d3ff709a392b2acd8f18b2bed669b47

You can also check the HTML of the email to check if it is correct by selecting the "Check HTML" tab, the result is an analysis of the HTML code lines that are being violated:

c8a7fa5b8ba37f66a3dd9c18a467a3cb36768fb2

Finally, a tab that you cannot ignore – "Analysis" tab, provides you with analysis, reports on spam points and the blacklist of your messages and servers.

With such support, Mailtrap is an effective way to debug the content and markup of email messages you have sent.

3. Share inboxes and messages with your team

If your team has many other members who need to use the mailing function, and everyone needs to access your inbox to check the email sent? So there are 2 ways you can share your inbox:

  1. When your friend uses the free account:

There is no other way that you share your account with them, so they can access your mailbox on their device ^^.

  1. When they use premium account:

You can invite all developers (who have paid accounts) to access each mailbox via the link provided (this link will change when you click "Regenerate share link" link). Share steps are as follows:

  • Step 1. Click "Company users" link on the Settings screen of the inbox you want to share.

b08ca71368a1d08bea1579ae0cc6075cdc01f5c1

Step 2. Send the generated system link to the user you want to invite.

af1bf2d57b11e721aea9a627c02408d6066cdedc

You can also easily see the function of automatically forwarding all emails that Mailtrap receives to those who need it. However, this function is only available for paid accounts only ^^.

If you already have a paid Mailtrap account, and have used it effectively, don't forget to share it with me and everyone else.

Conclusion: If you are a Tester, you are not allowed to "touch" sourcecode. So you can't configure it now, how to test mail sending with Mailtrap? Simple, please ask your dev to configure it on your device, then ask for your Mailtrap account (that's in case you use a free account) or ask him to share inbox for (in case You use a genuine account: P), go back to your computer, log in to Mailtrap, that's it! Then, you can freely test the mail sending function of the system, but no longer afraid that the spam mail you create affects the real users of the system.

Reference articles from links: https://code.tutsplus.com/tutorials/introduction-to-mailtrap-a-fake-smtp-server-for-pre-production-testing–cms-23279

https://mailtrap.io/

ITZone via Viblo

Share the news now