Setting up your own Bulk Mail Server — using Sendy and AWS

Setting up your own Bulk Mail Server — using Sendy and AWS

·

29 min read

It’s been a while since I’ve written a tutorial. Life came in the way and all my project ideas went on the back burner. But now, at my new job, I was forced to re-evaluate the way newsletters and bulk mails were sent and that’s when I came across Sendy . And it’s brilliant — a clean solution and interface for sending bulk mail. I haven’t been hired by Sendy to work on this tutorial; I genuinely like this product and hope that the following tutorial helps someone out there.

There is one very detailed Sendy on AWS tutorial that I would like to highlight here, without which I would not have been able to even start my project — https://colcol.co.uk/introduction-to-installing-sendy-and-virtualmin-on-aws/ My tutorial varies slightly as I have a bit of a tech background already so I was able to shorten the steps a bit. Also, I set up on Ubuntu 18.04 using a LAMP setup.

You don’t need a highly technical background to go through this tutorial, at the most you just might be slower at the setup. I’ve also added some troubleshooting and problems I encountered with the new version of Virtualmin and some ways to save money on the EC2 instance.

Some points to note:

  1. You must use the Ubuntu Server version so that its GUI-less. Saves on installation space.
  2. I tried and tested on the free tier (t2.micro type EC2) but it crashed a lot. Other tutorials online say it’s possible but I don’t know if Virtualmin upgraded or Sendy or the OS but eventually I had to shift to a t2.small and it’s working a lot better. I’ve left a note on how to start/stop instances automatically so you can save on some money there.
  3. You need to own your own domain to set this up.
  4. I have used Amazon SES to set this up instead of my own SMTP server.
  5. The reason I also chose EC2 over maybe a raspberry pi is because AWS gives you 62,000 emails free per month if your bulk mail server is hosted on EC2. Also, with the pi, you will be responsible for maintaining the internet etc.

So what is this tutorial about…

Basically, my company was paying a tonne of money to send out bulk mail. And this isn’t even on a service like Mailchimp; so I can’t imagine how much a full service like that would have cost. Hence I decided to look for another solution which would give me a Mailchimp like interface but self-hosted so it reduces costs.

I found Sendy to be a great option for the interface because they pretty much cover all the features except for the drag and drop HTML email builder (I found another nice solution for this which I will add on in the tutorial). Although, they have a one-time fee, it’s worth it because this means the software is maintained and the creator is pretty regular answering questions in the Sendy forums. I also landed up buying Sendy on Black Friday and they gave a nice discount :) So if you are close to a holiday, check for a discount.

Essentially, Sendy is installed on an EC2 instance on AWS along with Virtualmin as the control panel for the server. AWS SES is used as the SMTP server to send out the emails. This is handy as you probably know that trying to send bulk mails from your own email will cause your email to be blocked since it looks like spam. So using a bulk mail SMTP server is important.

Let’s start!

Ok, let’s not waste any more time. Let’s get into project mode and get going with our own bulk mail server.

What will you need

  1. A verified AWS account — verification can take some time so plan ahead.
  2. A Sendy license — they are pretty quick at sending the details after you buy it online.
  3. I use an Ubuntu 18.04 computer myself since most of the work will be done via SSH. If you are on Windows, you will need Putty installed to SSH into your EC2 instance.
  4. A domain that you own and have access to its DNS configuration.

Outline of major steps

  1. Create a Security Group
  2. Create an EC2 instance
  3. Set up config file for your key pair
  4. Set up Elastic IP address
  5. Connecting to EC2 via SSH
  6. Installing Virtualmin
  7. Create a server on Virtualmin
  8. Setting up SSL
  9. Installing Sendy
  10. Setting up Amazon SES
  11. Verifying domain on SES
  12. Setting up Cron Jobs

Optional suggestions

  1. Backing up/Restoring your Sendy database
  2. Automatic start/stop of EC2 instances
  3. Using MJML to create awesome HTML emails
  4. Automate backups of Sendy on AWS using Snapshots
  5. Updating your Sendy installation

As you can see, there are quite a lot of steps so pace yourself. Sometimes the DNS configurations take some time to take effect and I would recommend testing the server for a week or so to see how well it runs for your needs.

Create a Security Group

  1. Login to your AWS account .
  2. Make sure you change your region to the one you want in the top right corner. A good way to choose this is that if most of your emails will be sent from UK, then select a UK based region.
  3. Under the Services tab in the top left (this is where what we will be using to navigate through AWS), find/select EC2.
  4. On the left-hand side menu, select Security Groups.
  5. Click Create Security Group.
  6. Enter the following details and rules:
    Name: Sendy Bulk Mail
    Description: HTTP, HTTPS, SSH, Virtualmin
    VPC: default
    Rule 1: HTTP (leave defaults)
    Rule 2: HTTPS (leave defaults)
    Rule 3: SSH, select My IP — this will be used to SSH into the computer and only really should be your IP address. If you have multiple locations that you work from, you can add all, just make sure you give them appropriate descriptions.
    Rule 4: Custom TCP, select My IP, Port: 10000 — this will be used to access Virtualmin
    
  7. Click Create.
  8. Once created, you will see the Security Group in your list of Security Groups. Here, you can add a name to the group. Hover in the first column, Name and you will see a pencil icon. Click and edit.

Create and EC2 Instance

  1. Double check your region.
  2. Navigate to EC2.
  3. From the left-hand side menu, select Instances.
  4. Click Launch Instance.
  5. Select Free tier only on the left.
  6. Select Ubuntu Server 18.04 LTS.
  7. Click Next.
  8. For Instance Type there is only one eligible on the free tier and that is t2.micro but this did not work for me with Sendy and Virtualmin. I went for the t2.small and it has been running pretty smoothly for the last month. It’s not that expensive and I have suggested a way to stop the Instance when not in use to save some money since AWS has hourly billing.
  9. Click Next: Configure Instance Details.
  10. Make sure you select Protect against accidental termination because if you terminate your instance, you will lose all your data. There are ways to set up your data in a way that doesn’t get deleted, but restoring it is beyond the scope of this tutorial.
  11. Click Next: Add Storage.
  12. Enter 30GB as the disk size. This is the maximum allowed on the free tier. This is where you can also select not to delete on termination but as I said restoring it is beyond this tutorial. The rest can be left as defaults.
  13. Click Next: Add Tags.
  14. No need to add any tags.
  15. Click Next: Configure Security Group.
  16. Select Select an existing Security Group.
  17. And select the Security Group that we created in the previous section. It is called Sendy Bulk Mail in this tutorial.
  18. Click Review and Launch.
  19. Make sure all your settings are correct.
  20. Click Launch.
  21. If you haven’t used AWS before, you will be asked to create a new key pair.
  22. Enter a name and download the file. You can only do this this one time, so please make sure you have it saved somewhere safe.
  23. Once the EC2 is launched, you can enter an instance name to make it easy to differentiate. For example, Sendy Server.

Set up key file to login into EC2

  1. Move the downloaded key file to your .ssh folder.
  2. The permissions for the file needs to be changed otherwise AWS gives an error while trying to login with this key file — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#troubleshoot-unprotected-key
  3. Open a terminal and navigate to your .ssh folder.
  4. Enter the following: chmod 400 <mykey>.pem

Set up config file for your key pair

Generally, when logging into an EC2 instance via SSH, you need to also pass in the pem file, making the ssh command a bit cumbersome. A config setting helps to point a key file to Amazon so that you don’t need to enter the key file every time.

If you don’t wish to set up a config file, this is what your ssh command would typically look like and this is what you should follow, should you wish to not create a config setting,

ssh -i /path/<mykey>.pem ubuntu@ec2-198-51-100-1.compute-1.amazonaws.com
  1. Open a terminal and navigate to your .ssh folder.
  2. If you don’t have a config file, then touch config
  3. Then edit the config file with nano config
  4. Based on what image you installed, your instance’s username will change. Find complete list here — https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-get-info-about-instance For this tutorial, we installed an Ubuntu image; so the username is ubuntu.
  5. Append the following in your config file:
    Host *amazonaws.com
    IdentityFile ~/.ssh/<mykey>.pem
    User ubuntu
    
  6. Ctrl+O (to save the changes), then Ctrl+X to close the editor.

Set up Elastic IP address

An Elastic IP on AWS is a really handy way for your domain to point to the EC2 server. They are free to use under the AWS free tier as long as it is associated with an EC2.

  1. On your EC2 dashboard on AWS, select Elastic IPs.
  2. Click Allocate Elastic IP address.
  3. Select Amazon’s pool of IPv4 addresses.
  4. Click Allocate.
  5. Now click the newly allocated IP address and select Associate IP address either from the Actions menu or from the success message that pops up when you allocate the IP address.
  6. Select Instance.
  7. Select your EC2 instance for Sendy.
  8. Click Associate.
  9. Go back to your EC2 Instances , click on the instance and look in the description tab below. Make sure the public IP is the same as the Elastic IP, we just created.

Add Elastic IP to your domain’s DNS records

Now, we need associate your domain or subdomain with this IP address. This is the domain you will use to access Sendy. I recommend creating it as a subdomain to your website, something like sendy.<mydomain>.com since your main domain is where you would ideally host your website (for which you might need newsletters). This will be the URL for your Sendy installation.

Every domain host will have its own platform but essentially, you need to login to your domain host control panel and navigate to DNS settings/records or Advanced DNS settings/records.

Once you are in the right place, you need to add an A record. The hostname will be sendy if you wish it to be a subdomain as in sendy.<mydomain>.com or leave blank if you’re using the root domain.

Note: This takes a few hours to associate so in case you land up finishing this tutorial quickly, don’t panic if your Sendy website is still not loading. Sleep on it :)

Connecting to EC2 via SSH

  1. On your AWS console, navigate to your EC2 Instances (via the Services menu, if needed).
  2. On the list of EC2 instances, click on the instance you wish to install Sendy on; the one we created in this tutorial.
  3. In the description tab below, find the public DNS and copy it.
  4. Open your terminal.
  5. Enter ssh <my-EC2-public-DNS>
  6. Accept the fingerprint message and you’re logged in.

Update the OS

  1. Once you’re logged into the EC2, let’s take this opportunity to update the operating system before we start installing the rest of the software.
  2. sudo apt-get update
  3. sudo apt-get upgrade
  4. sudo apt-get full-upgrade
  5. sudo reboot
  6. When you reboot, you will be disconnected from the EC2.

Installing Virtualmin

In order to get Virtualmin up and running, we must first make some edits to the hostname of your EC2 server.

Edit hostname

  1. Login to your EC2 via ssh.
  2. Once logged in, enter the following: sudo nano /etc/hostname.
  3. There will be one word there which represent the hostname of the server — change it to sendy.
  4. sudo reboot
  5. Log back in.
  6. Your server name should be updated in the prompt.
  7. Now, we need to update the host file — sudo nano /etc/hosts.
  8. Add the following 127.0.1.1 sendy.<mydomain>.com. This is assuming Sendy is using the subdomain sendy, if not, then simply add <mydomain>.com.
  9. sudo reboot — it’s always good to reboot after making changes in any configuration.

Install Virtualmin

  1. Log back into your EC2 via ssh.
  2. First we need to download the install file — wget http://software.virtualmin.com/gpl/scripts/install.sh
  3. Run the install file — sh ./install.sh --minimal. We are going to use the minimal setup since Sendy doesn’t need the additional files that come with Virtualmin. Although, if you will be hosting the website at the same location, you might need the full installation of Virtualmin. The details of that go beyond the scope of this tutorial.
  4. Enter y to continue.
  5. You might be asked to enter an FQDN — enter your Sendy URL. In the case of this tutorial, it will be sendy.<mydomain>.com.
  6. The installation happens in 3 phases and takes a bit of time.
  7. Once the installation is complete, change Virtualmin’s root password — sudo /usr/share/webmin/changepass.pl /etc/webmin/ root <mypassword>

Note: I experimented with many versions of Ubuntu and settings when setting up Sendy, and I noticed that on Ubuntu 16.04, there was a locale issue when installing Virtualmin, here is the solution — https://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue

Virtualmin Post-Installation Wizard

  1. After changing the password, open your browser and enter your Sendy URL like so — sendy.<mydomain>.com:10000
  2. Login with username as root and password as what you just created in the previous section.
  3. After logging in to Virtualmin, you will see the Post-Installation Wizard.
  4. Click Next on the first Introduction page.
  5. Since we are using Virtualmin to simply monitor Sendy, select No for Preload Virtualmin libraries? and Yes for Run email domain lookup server?. Click Next.
  6. Select No for Virus scanning. Click Next.
  7. Select No for Spam filtering. Click Next.
  8. In Database servers, select Yes for MySQL and NO for PostgreSQL. Click Next.
  9. Set a root password for MySQL. This should be different from the root password you set for Virtualmin. Click Next.
  10. For MySQL database size, I selected Large since I have emails in the hundreds but I wanted to leave room for it to grow; large should be sufficient for Sendy. This really depends on you. Click Next.
  11. Your Primary nameserver is the Sendy URL — sendy.<mydomain>.com Click Next.
  12. Select Only store hashed passwords. Click Next.
  13. On the All done page, simply click Next.
  14. Now Virtualmin will have to be refreshed. Click Re-check and refresh configuration.
  15. A bunch of installation messages will appear and once all the steps are complete, you should see a system is ready message.

Create a server on Virtualmin

  1. Login to Virtualmin at sendy.<mydomain>.com:10000.
  2. Make sure you are on the Virtualmin tab (left hand side menu, right on top, there are two options: Webmin and Virtualmin).
  3. Click Create Virtual Server.
  4. Enter the following details:
    Domain name: sendy.<mydomain>.com
    Administration password: a password that is different from the other passwords you have set in this tutorial.
    Administration username: Automatic (this will make your username the subdomain of your Sendy URL. In this case, sendy.
    
  5. Under Enabled features, I had the following checked,
    DNS domain enabled?
    Apache website enabled?
    MySQL database enabled?
    Webmin login enabled?
    Apache SSL website enabled?
    
  6. Click Create Server.
  7. Various setup messages will come up. Once the server is created, you will see it on the top of your left hand side menu.
  8. When you click it, you will see a summary of it such as the username for which we had selected Automatic in step 4.

Setting up SSL

  1. Click on Server Configuration on the left menu of Virtualmin.
  2. Click SSL Certificate. Note: If you don’t see SSL Certificate as an option, then it is possible, that you haven’t enabled it. Click Edit Virtual Server and select Enabled features. Check Apache SSL website enabled?.
  3. Click Let’s Encrypt on the top menu.
  4. Under Request certificate for, you can either enter the domain names names manually (in case you have ones different from the default) or leave them as the default domains.
  5. Click Request Certificate.

    Note: If you get an ACME error when you try to request the certificate, you will need to install a tool on your EC2 instance. Login via ssh into your EC2 and sudo apt-get install certbot , then sudo certbot register . Enter your email address and reboot the EC2 instance sudo reboot. Reference: cloudmin.com/node/67390

  6. Go to Let’s Encrypt on your Virtualmin sendy.<mydomain>.com:10000.
  7. When you click Request Certificate, there shouldn’t be an error this time.
  8. Click Current Certificate in the top menu.
  9. Click Copy to Virtualmin.
  10. Logout of current Virtualmin page.
  11. Open a new browser window and navigate to your Virtualmin sendy.<mydomain>.com:10000.
  12. This time the connection will be secure.

Installing Sendy

Configuring MySQL database

  1. SSH into your EC2 instance.
  2. Enter mysql_secure_installation.
  3. This will ask you a series of questions to secure your SQL server.
  4. The configuration is upto you; these are the settings I followed:
    Validate Password plugin: n
    Root password: The one you set in the post-installation wixard of Virtualmin.
    Remove anonymous users: y
    Disallow root login remotely: y
    Remove test database and access: y
    Reload privilege tables: y
    
  5. Sendy needs an edit in the SQL configuration to make it run properly. Reference: sendy.co/forum/discussion/7752/#Item_6
  6. Enter the following in your terminal to EC2 instance sudo nano /etc/mysql/mysql.conf.d/mysql.cnf.
  7. At the end of the [mysqld] section, there is a list of SQL modes. Make sure that ONLY_FULL_GROUP_BY is removed.
  8. The list might look like this after editing:
    sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
    
  9. Restart MySQL service sudo service mysqld restart

Setting up Sendy

  1. Download Sendy with the link you received in your email at the time of buying the license. Let the files be on your computer right now as we need to make some edits to the configuration.
  2. While it’s downloading, navigate to your Virtualmin.
  3. Click on Edit Databases on the left menu.
  4. Click Passwords from the top menu.
  5. Hover over the key symbol to get your user name and password. Take a note of them.
  6. Once Sendy has downloaded on your local computer, unzip it.
  7. Open the file includes/config.php.
  8. Update the required details:
    Installation URL: sendy.<mydomain>.com
    Hostname: localhost
    Username: The user name you retrieved from Virtualmin
    Password: The password your retrieved from Virtualmin
    DB name: sendy
    
  9. Copying the sendy files into the EC2 is slightly complicated and there are many ways of doing it, I’m sure even better than mine. So do experiment here if you are doing this project as a learning experience. I would be happy to hear suggestions of different ways of doing it than the one I have outlined:
    I use Filezilla to copy over the files
    When VirtualMin is installed, it creates a new user called sendy (assuming you followed naming conventions in my tutorial)
    To use Filezilla, you will have to login to the EC2 as this sendy user. In order to do that, you need to give this user SSH access.
    Once you give it SSH access, you can login using Filezilla and copy necessary files.
    
    Steps are detailed below.
  10. SSH into your EC2 instance in the usual way.
  11. First, we must get the public key part of the private key (the .pem file) we downloaded from AWS. Enter cat .ssh/authorized_keys. Copy the output beginning with ssh-rsa. Save this on some text editor for the time being. Remember to discard it later.
  12. Now we must switch over to the sendy user on the EC2 instance. Enter sudo su sendy
  13. You will see your prompt change to sendy
  14. Create the SSH directory for this user:
    mkdir .ssh
    
  15. Change the permission for the SSH folder. This is important when dealing with keys:
    chmod 700 .ssh
    
  16. Create an authorized_keys file:
    touch .ssh/authorized_keys
    
  17. Change the permissions on the file:
    chmod 600 .ssh/authorized_keys
    
  18. Let’s add that public key, we copied from the EC2 main user.
    nano .ssh/authorized_keys
    
  19. Copy the key (not your .pem key but the public key we copied earlier) into the file. Ctrl+O , Ctrl+X to save the file.

    Note: These steps have been adapted from here: docs.aws.amazon.com/AWSEC2/latest/UserGuide..

  20. Login to your EC2 instance on Filezilla. The details will be the same as your SSH login but this time instead of ubuntu as the username on Filezilla, enter sendy.
  21. Copy the files over from your local computer (on the left pane) to the directory on EC2 at /home/sendy/public_html/ (right pane).

    Note: Make sure the hidden file .htaccess has copied over as well.

  22. Incase the user and group owners have changed on the EC2 isntance while copying over, change them to sendy by SSH’ing in again (or on Filezilla):
    sudo chown -R sendy:sendy /home/sendy/public_html
    
  23. Install some libraries that are needed by Sendy:
    sudo apt-get install libcurl4-openssl-dev php7.2-curl
    
  24. sudo reboot
  25. Once the EC2 has rebooted, navigate to your Sendy URL — sendy.<mydomain>.com.
  26. If you see a 500 error, follow this link to correct it — sendy.co/troubleshooting#500-error

    Note: You can use Virtualmin’s File Manager to edit text files.

  27. sudo reboot
  28. Navigate to Sendy — sendy.<mydomain>.com
  29. You should see an install page now. In the server compatibility list is mod_rewrite is not enabled, that’s alright. This is generally not enabled when installing on AWS.
  30. Fill in all the details. The login details would be for the administrator login. The AWS details can be left blank for now. We will fill that up in the next section.
  31. Once the details are filled in, click Install now.
  32. You should now see the login page where you can enter the email and password you set on the previous install page.

Setting up Amazon SES

  1. Login to your AWS console .
  2. Navigate to IAM using the Services menu.
  3. Make sure that your region is set correctly in the top-right.
  4. Click on Users on the right menu.
  5. Click Add User.
  6. Enter the following details:
    User name: sendy
    Access type: Programmatic access
    
  7. Click Next: Permissions.
  8. Select Attach existing policies.
  9. In the search type sesf . Select AmazonSESFullAccess.
  10. In the search type snsf . Select AmazonSNSFullAccess.
  11. Click Next: Tags. This section can be skipped.
  12. Click Next: Review. Review your settings.
  13. Click Create User.
  14. Copy the credentials on a temporary text file so it will be easy to enter into Sendy. Or alternatively, open Sendy side by side and copy directly.

    Note: Make sure you get rid of the temporary text file with the credentials after you have copied them over.

  15. Go over to your Sendy — sendy.<mydomain>.com and in the top right drop down menu, select Settings.
  16. Add your AWS credentials under Amazon Web Services Credentials and also select your AWS region under Amazon SES region.
  17. Click Save.

Verifying domain on SES

When you first start using AWS SES, it will place you in a sandbox environment where you can send limited emails and only from verified emails or domains. This is to encourage you to test your bulk mail server before sending newsletters to your clients. Use this time to thoroughly test and learn how Sendy works because your mistakes won’t have any effects here. It’s also a good time to check whether Sendy is set up properly on AWS and if your EC2 instance type is ideal for what you need. In my case, I had started with t2.micro (for the free tier) but Sendy crashed a lot so I eventually had to upgrade.

Note: When you have tested enough and are ready to increase your limits on SES and get out of the sandbox environment, you need to make a request to AWS. Find details here — docs.aws.amazon.com/ses/latest/DeveloperGui..

  1. Login to your AWS console and navigate to SES.
  2. Click Domains on the left menu.
  3. Click Verify New Domain.
  4. Enter your domain. This domain should match the domain you hosted your Sendy on — <mydomain>.com without the sendy sub-domain part.
  5. Check Generate DKIM Settings.
  6. Open your domain’s control panel where you can set the DNS records. As we did in the previous section when setting the Elastic IP.
  7. There should be two types of records to add: Domain Verification Record (TXT) and DKIM Record Set (CNAME). Add them to your DNS settings.

    Note: If your domain already has email associated with, do not add the Email Receiving Record.

  8. Check your email associated with your AWS account and shortly, you should receive confirmations of the domain being verified.

This is an important step because it reduces the chances of your newsletters going in to client’s spam mail. Now you can start playing around with Sendy as long as the emails are only sent to and from your domain.

In case you want to try sending to other emails you own, like a personal one, for testing, you will have to verify the individual emails by clicking on Email Addresses on the left menu.

Note: AWS provides a great Mailbox Simulator to test email behaviour on Sendy — docs.aws.amazon.com/ses/latest/DeveloperGui..

Updating your MAIL FROM Domain (optional)

  1. Once your domain is verified, click on it in the list of Domains on your SES console.
  2. Here you can see the settings for your domain, such as the records we added in the previous section.
  3. One additional feature is to use a MAIL FROM domain. If you try sending an email from Sendy (to yourself for example), you can see in the email header, that the email is mailed-by . You can try it out by observing other newsletters you might have received. Some people show a personalised domain and others just show the raw server name. For example, AWS newsletter come from bounce.amazon.com . bounce is a common sub-domain used for newsletters, but it’s really up to you.
  4. Back on the AWS console, open the MAIL FROM Domain section. And click Add MAIL FROM Domain.
  5. Make sure that the MAIL FROM domain is different from your Sendy sub-domain and isn’t being used by any other part of your domain. There are various options like bounce.<mydomain>.com or mail.<mydomain>.com or info.<mydomain>.com.
  6. You will have to set two types of DNS settings on your domain’s control panel: MX Record Settings (MX) and SPF Record Settings (TXT). Note: Don’t worry an MX record for a sub-domain does not clash with your main domain’s email.
  7. You should receive an email once this domain is verified by AWS.

Setting up Cron Jobs

Sendy recommends you to add four cron jobs:

  • Importing CSVs
  • Schedule campaigns
  • Activate autoresponders
  • Updating sebments

Even though the cron jobs are not required, it’s good to add them in case something happens to your server, Sendy can resume whatever task it was doing.

Below is the snippet from Sendy on the details of the cron jobs,

To import large CSVs more reliably and have Sendy handle server timeouts, add a cron job with the following command.
Time Interval
*/1 * * * * 
Command
php /home/sendy/public_html/import-csv.php > /dev/null 2>&1
(Note that adding cron jobs vary from hosts to hosts, most offer a UI to add a cron job easily. Check your hosting control panel or consult your host if unsure.).
The above cron job runs every 1 minute. You can set it at 5 minutes (eg. */5) or any interval you want. The shorter the interval, the faster your CSV will start to import. Once added, wait for cron job to start running. If your cron job is functioning correctly, the blue informational message will disappear and future CSV imports will be done via cron.
________________________________________________
To schedule campaigns or to make sending more reliable, add a cron job with the following command.
Time Interval
*/5 * * * * 
Command
php /home/sendy/public_html/scheduled.php > /dev/null 2>&1
This command needs to be run every 5 minutes in order to check the database for any scheduled campaigns to send.
(Note that adding cron jobs vary from hosts to hosts, most offer a UI to add a cron job easily. Check your hosting control panel or consult your host if unsure.).
Once added, wait around 5 minutes. If your cron job is functioning correctly, you'll see the scheduling options instead of this modal window when you click on "Schedule this campaign?".
_____________________________________________
To activate autoresponders, add a cron job with the following command.
Time Interval
*/1 * * * * 
Command
php /home/sendy/public_html/autoresponders.php > /dev/null 2>&1
This command needs to be run every minute in order to check the database for any autoresponder emails to send.
(Note that adding cron jobs vary from hosts to hosts, most offer a UI to add a cron job easily. Check your hosting control panel or consult your host if unsure.).
Once added, wait one minute. If your cron job is functioning correctly, you'll see the autoresponder options instead of this modal window when you click on the "Autoresponders" button.
____________________________________________________
Add a cron job that runs every 15 minutes with the following command:
Time Interval
*/15 * * * * 
Command
php /home/sendy/public_html/update-segments.php > /dev/null 2>&1
(Note that adding cron jobs vary from hosts to hosts, most offer a UI to add a cron job easily. Check your hosting control panel or consult your host if unsure.).
Once added, wait for the cron job to start running in 15 minutes. If your cron job is functioning correctly, the blue informational message will disappear and your segmentation results will be updated automatically every 15 minutes by the cron job.

Adding cron jobs on Virtualmin

  1. Navigate to your Virtualmin — sendy.<mydomain>.com:10000 .
  2. In the top-left select Webmin.
  3. Under System, click Scheduled Cron Jobs.
  4. Click Create a new scheduled cron job on top.
  5. Enter the following Job Details:
    Execute cron job as: root
    Active?: Yes
    Command: Here enter the command of the cron job you are adding. For example, for importing CSVs, enter php /home/sendy/public_html/import-csv.php > /dev/null 2>&1.
    
    You can get the commands by looking on your Sendy or I have listed them above.

    Note: The path to the php file may vary if your Sendy installation was not installed on sendy.

  6. The rest can be left empty or you can add a Description.
  7. For When to execute, this is really upto you, Sendy gives you guidelines on the best times to execute. For example, for importing CSVs, they suggest every 1 minute. See under Time Interval in the cron jobs listed above.
  8. For Date range to execute, it’s probably best to select Run on any date.
  9. Click Create.
  10. Do this for the rest of the cron jobs.

Optional suggestions

Below are some options that you can use or incorporate in your Sendy.

Backing up/Restoring your Sendy database

It’s a good idea to play around with this before you actually start using Sendy. You might need to transfer your Sendy to another server or move to a larger database etc.

Backing up

  1. Navigate to your Virtualmin — sendy.<mydomain>.com:10000 .
  2. Click Edit Databases on the left menu.
  3. Click Manage next to your database, should be named sendy .
  4. At the bottom, click Backup Database.
  5. In the section Backup to file, select Download in browser.
  6. At the bottom, click Backup Now.
  7. The sql file will be downloaded.

Eventually, I would like to automate this process but haven’t had the chance to do so. Would love some suggestions.

Restoring

  1. Navigate to your Virtualmin — sendy.<mydomain>.com:10000 .
  2. Click Edit Databases on the left menu.
  3. Click Manage next to your database, should be named sendy .
  4. Click Execute SQL at the bottom.
  5. Click Run SQL from file.
  6. Select From uploaded file, assuming you have downloaded the backup from the previous section.
  7. Attach your .sql file. Typically called backup.sql.
  8. Click Execute.

Automatic start/stop of EC2 instances

This is a great option for anyone using a paid version of the EC2 instance. AWS charges by the hour, so any hours that the EC2 is offline, is money saved. Only drawback is that while your instance is off, Sendy cannot send any scheduled campaigns nor will it be gathering click data from your newsletters.

In my case, the emails were targeted to people in only one region, so having it offline during the middle of the night made sense.

I’m not going to rewrite the steps here because AWS has already covered each step in detail in their article here — aws.amazon.com/premiumsupport/knowledge-cen..

Using MJML to create awesome HTML emails

Unfortunately, Sendy doesn’t provide WYSIWYG editor so if you want to write some HTML newsletters, you’ll need to find another way to do it. I tried at least ten of them before I settled on MJML . I am absolutely amazed by it. It’s super easy to use and the documentation has enough tutorials and examples to make your own.

The MJML code is clean and simple and if you’re using one of their supported editors, you can easily convert everything to HTML and copy into Sendy’s templates. My personal favourite is Visual Studio Code that has a plugin for MJML with which you can have a live view of what the newsletter will look like while you are coding it and you can also convert to HTML, among other things.

Automate backups of Sendy on AWS using Snapshots

As your database on Sendy grows, it’s a good idea to start keeping backups of your server, primarily your database of signed up customers. And also avoiding setting up the server all over again.

AWS already has a tutorial in place to automate these backups — aws.amazon.com/premiumsupport/knowledge-cen..

There are many ways to backup your data and it might be that using snapshots will get expensive. So explore your options before you go ahead with this.

Updating your Sendy installation

I created this post a few months back and now the time has come that Sendy has made some updates.

Note: I also made a new update to the way Sendy is first installed on the EC2 in this tutorial. Initially, I had a slightly cumbersome way of first copying files into your Ubuntu home directory on the EC2 and then SSH’ing in and copying them over to the public_html directory. So for readers who used this older method, I have updated it to directly SSH into the sendy user on the EC2. You can scroll up to the section called Setting up Sendy to see the updates for this part. The following section assumes you can SSH into the sendy user.

It’s pretty straightforward to update Sendy.

  1. You will probably see a message at the bottom of your Sendy page saying there is an update available. Click that and you will be prompted to download the new Sendy on your local machine.
  2. You will also see some instructions by Sendy on how to update your system. It is important to look at these instructions as each update might require you to do something in particular. The steps below assume you have looked at that.
  3. Generally, once you download the new sendy files and unzip them on your local machine, you will be asked to copy over the /includes/config.php file from your EC2 instance. This is important. The new config file that will come with your sendy download won’t have your database configuration saved. So copy, over the old config.php into this newly downloaded installation files. You can do this directly through your VirtualMin page under File Manager.
  4. If you have downloaded additional language files in /locale/ then copy those over from EC2 to your local machine.
  5. If you have made changes to the .htaccess file then download that too.
  6. Replace the new build with the downloaded files — config.php, /locale/, .htaccess
  7. Login into your EC2 instance on Filezilla by using your usual SSH details for the EC2 but changing the username to sendy .

    Note: For readers who used this tutorial before 12 May 2020, scroll upto Setting up Sendy to see how to login into your EC2 instance using the sendy user.

  8. Copy and replace the sendy installation files from your newly downloaded sendy installation to the EC2 instance directory of /home/sendy/public_html/.
  9. Refresh your Sendy page and you should see the new changes (and the new version available message is gone). If you don’t see the changes, your computer could have cached the page so Ctrl+Shift+R.

Wow that was a long tutorial. There are going to be some errors, I apologise in advance. I have read it several times but it’s quite long! Please do point out anything that is off.

Hope this guide was useful and if there are any comments/edits/problems/questions, please do ask away :) All feedback is welcome. Feel free to ask any questions via Twitter as well — twitter.com/neha_m25