most people restrict their browser testing within a site. However, with a shopping cart or subscription application for example, the testing should really end only after the user receives the email as anything could happen between the moment email is sent and received. Email testing can be tricky. How does one automate the process of checking emails and verifying the right email has been sent without too much of a hassle? Well, the trick is to setup an internal mail server and install a HTML capable email client within the test machine.
Here, I’m going to quickly set up my virtual machine to handle sending and receiving of internal mails.
1. Install dovecot bundle
sudo apt-get install dovecot-imapd dovecot-postfix
(When asked to configure postfix, choose “localhost only”. We don’t want to accidentally send email to the outside world)
2. Create a new test user for testing
3. Install squirrelmail (Any other web-based client is fine as well). Remember to log in as the test user and set HTML email as the default first.
4. When running the browser test or BDD, use firstname.lastname@example.org as user’s email. When logged into squirrelmail, you can then automate the checking and clicking of the test receipt links.