By Jeff Cleverley, Alibaba Cloud Tech Share Author
Mautic is the world's largest Open Source marketing automation project, with over 1000 contributors to the project. It is available in 35 languages and used by over 200,000 organizations.
Effective marketing campaigns use a network of multiple channels and involve a lot of repetitive tasks with interrelated complexities. Mautic, and other similar software, are powerful tools that make these complex and repetitive tasks easy. Marketing automation software tracks every lead, or visitor to your website and other online locations and analyzes visits to build a profile of visitors and automates actions based upon their activity. Integrations with popular Customer Relationship Management (CRM) software provide a constant stream of high quality leads ready to be converted into sales and clients.
Marketing Automation is like a bridge between your leads and your customers.
Mautic provides a mechanism to develop and target multi-channel marketing resources, from dynamic web content and landing pages, forms, automated email engagement and marketing, to web notifications, text messages, tweets, and social monitoring. It has integrations with third party platforms including Salesforce CRM, Sugar CRM, Microsoft Dynamics CRM Zoho CRM, FullContact, MailChimp, ConnectWise, and many more. Since it is open source, it is also completely customizable with a healthy developer community building all manner of other integrations.
Mautic is built on Symfony, the highly popular and extremely performant PHP framework, and will run on either a LEMP or LAMP stack.
In today's tutorial we are going to install Mautic on a LEMP stack, using the Webinoly optimized server automation tool. We will then set up an Alibaba Cloud DirectMail email account to use as the SMTP provider for Mautic emailing.
In the code and command examples I will be using 'example.com' as the domain. This will need to be replaced by your own domain when you follow along. In the images used to illustrate each step, I have used a free domain I had available 'duang.party', again remember in your commands use your own domain.
Before you begin this tutorial, you should have an Alibaba Cloud ECS instance provisioned and running, with at least 1GB of memory.
You should have uploaded your public SSH key to the server during provisioning so that you can access your server by SSH in the terminal. If you haven't done this before, you can find instructions in this tutorial.
You should also have a domain name available to use.
Step 1. Open Security Group Ports
If you have created your instance, you should be viewing it in your Alibaba Cloud ECS Management Console. Locate 'Security Groups' from the left horizontal navigation bar and click it to go to your Instance's Security Group:
<Click Security Groups on your Instances Page>
<Choose Configure Rules for your Security Group>
You will now be taken to a page with two tabbed panels. One tab will show you your Inbound Security Group Rules, the other will show you the Outbound rules.
Webinoly Requires the following inbound Ports open:
• 22/22 (SSH)• 80/80 (HTTP)• 443/443 (HTTPS)• 2222/2222 (Webinoly Tools)
Each Port should be using the following further settings:
Authorization Type: Address Field Access Authorization Object: 0.0.0.0/0
When you have completed this, your Security Group Rules Inbound tab should look like:
<Security Group Inbound Ports>
Webinoly and Mautic require the following outbound Ports open:
• 22/22 (SSH)• 25/25 (SMTP)• 80/80 (HTTP)• 443/443 (HTTPS)• 11371/11371 (Access GPG Keys)
Each Port should be using the following further settings:
Authorization Type: Address Field AccessAuthorization Object: 0.0.0.0/0
When you have completed this, your Security Group Rules Outbound tab should look like:
<Security Group Outbound Ports>
Step 2. Configure Alibaba Cloud DNS
Now we need to go to the Alibaba Cloud DNS management section of your console, you can find this in the left horizontal main menu. Inside the Basic DNS section, click the blue 'Add Domain' button in the top right to add your domain:
<Open Alibaba Cloud DNS>
<Add your domain>
Your domain will appear in the list. Now you need to configure some DNS records for it:
<Configure DNS Records for your domain>
Your Domain's DNS settings should look similar to this:
<Configure your A and CNAME DNS records>
If you are using a domain with Alibaba Cloud Domains, then you should be finished here.
If you are using a domain registered with a third party domain registrar, you will need to log in to your account at your domain registrar and change your domain's nameservers (DNS servers) to point to the Alibaba Cloud nameservers.
You will find the correct nameservers provided at the top of your DNS records page:
<Make sure your domain nameservers are set to the Alibaba Cloud DNS servers>
Step 3. Configure Alibaba Cloud Direct Mail
In your Alibaba Cloud Console Home, locate 'Direct Mail' and click it:
<Alibaba Cloud Direct Mail in your Cloud Console>
Add an Email Domain
<Choose Email Domains first>
The click the 'New Domain' button in the top right:
<Click to create a New Domain>
You will need to add a domain. To avoid conflicts with your main domain email, choose a subdomain to use. I suggest prefixing your domain with 'dm .':
<Add a subdomain to use for Direct Mail>
Your new Email Subdomain will appear in the list. You now need to click configure:
<Click configure to get your Direct Mail Verification records>
A new window will open, it will provide you with several DNS records you need to set in your Alibaba Cloud DNS records for your domain. These are used for verification, and for receiving and tracking configuration:
<Alibaba Cloud Direct Mail provides you with additional DNS records>
Now go back to Alibaba Cloud DNS, and enter each of these records and their values in your domains DNS records.
Once you have added these records your domains DNS should look similar to this:
<Add the Additional DNS records to your Domains DNS>
Now you are ready to verify ownership of the email domain. Return to your email subdomain in Direct Mail and click verify:
<Click Verify in your Direct Mail email domain>
Assuming everything has been configured properly, your domain status should change to 'verification successful', highlighted in green:
<Email domain verification successful>
Add Sender Address and Set SMTP Password
Now open the Sender Addresses panel and click Create Sender Address:
<Sender Addresses panel - Create Sender Address>
Choose your email domain from the dropdown menu.
You will need to add an account name. This name will be used to create the sender address. This will be your SMTP username in the following format:
<Sender Account Name>@<Email Subdomain>
You will also need to set a Reply-To address. This is not the Reply-To address used by SMTP in Mautic, it is only used for communication with the Alibaba Cloud console, but it must be verified before you can progress and set up your SMTP password.
Next chose your mail type. You can choose either 'Triggered Emails' or 'Batch Emails'. In real world usage of Mautic, you would set up both, Triggered Emails for transactional emails, and Batch Emails for Email newsletters and mass mail-outs. For the purposes of this tutorial I will choose 'Triggered Emails '.
<Set your Direct Mail sender address>
Direct Mail will immediately send an email to the Reply-To address you set. You will need to go to your email inbox and click a link before you can proceed further.
Once you have verified your email, click on the 'Set SMTP Password ':
<Set your SMTP Password>
You will also require the the Alibaba Cloud Server Addresses when you set up Mautic. These can be found here.
Step 4. Install Webinoly LEMP Stack
Webinoly is an excellent tool that automates the installation of an optimized LEMP web server stack on any Ubuntu 16.04 Instance. It installs Nginx, MariaDB (MySql) and PHP7, alongside command line tools to automate the provisioning of Let's Encrypt SSL Certificates, FastCGI Static Caching, Redis and Memcached Object Caching servers, and logging tools to help manage your server stack.
Install the full Webinoly LEMP stack to your instance with the following command:
# wget -qO weby qrok.es/wy && bash weby 3
<Webinoly has been installed>
Step 5. Create Virtual Host & Root Directory
With Webinoly it is incredibly easy to configure your Nginx Virtual Host for your site.
Issue this command:
# site example.com -php
Webinoly will quickly respond with a success message:
<Create a site and virtual host with Webinoly>
Webinoly has now created the directory structure and root directory for your site and configured the Nginx virtual host configuration file necessary to run a PHP based site from it.
Your Nginx Virtual host configuration file is located at '/etc/nginx/sites-available/' and has been automatically symlinked into '/etc/nginx/sites-enabled /'.
You can open it to inspect it:
# nano /etc/nginx/sites-available/example.com
<Webinoly automatically configures your Nginx Virtual Host>
Your site root directory has been created at '/var/www/htdocs /'.
Step 6. Obtain an SSL Certificate with Webinoly
To obtain a Let's Encrypt SSL certificate and enable HTTPS on your domain with Webinoly, issue the following command:
# site example.com -ssl-on
You will be asked to provide an email address and a cron job will be created to automatically renew your certificate every week.
<Obtain a Let's Encrypt SSL with Webinoly>
Since Webinoly uses Certbot by Let's Encrypt, your Nginx Virtual Host Configuration file will be automatically updated to serve your site using HTTPS (port 443).
Step 7. Create your Mautic Database
Login to your MariaDB (MySQL) using your the root password provided earlier (when Webinoly completed installation):
# mysql -u root -p
Now create your database and the user you require by entering the following successive MySQL commands:
CREATE DATABASE mastic DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; GRANT ALL ON mastic.* TO 'new_user'@'localhost' IDENTIFIED BY 'new_users_password';
Make sure you choose a strong password. Once you have done this, flush privileges and exit MySQL:
FLUSH PRIVILEGES; EXIT;
<Create your Mautic Database>
Step 8. Download Mautic Files
Change directory into your site's root directory, and download the latest Mautic ZIP archive:
# cd /var/www/example.com/htdocs # wget https://www.mautic.org/download/latest -O mautic.zip
<Download the latest Mautic release>
Finally, unzip the archive:
# unzip mautic.zip
Step 9. Prepare Mautic Directory permissions
First, from within the root directory, delete the 'mautic.zip' archive, and then list out the directory with ownership and permissions:
# rm mautic.zip # ls -l
You will see that currently all of the Mautic directory contents are owned by the 'root' user:
<Root user still owns all the Mautic Files and Directories>
We need to make the web server user and group 'www-data' the owner of all of these files and directories.
Do that with the following command, and then list out the directory again to ensure everything has been successful:
# chown -R www-data:www-data /var/www/example.com/htdocs # ls -l
Now you should see 'www-data' as the owner of the root directories contents:
<www-data now owns the directory and its contents>
Step 10. Install and Configure Mautic
We have prepared everything we need, now we just need to run the Mautic installer, to do that just visit your domain:
Mautic will do an environment check, and let you know when it is ready to install:
<Mautic Installer Environment Check>
<Connect Mautic to your database>
Now we create an Administrative user:
<Create your Admin account>
The final step in the Mautic installer set up is the email configuration. These settings can be changed later from within Mautic, but we can set them up now.
Choose your sender and sender email.
Choose how you want Emails handled, immediately or queued.
In Server, enter the Alibaba Cloud Direct Mail server you will be using. You can get that server address here.
Choose Port 465 and SSL Encryption and Login Authentication mode.
Enter the SMTP username and Password you created in Step 3 above.
<Configure Mautic to use Direct Mail - Then click next step>
Mautic will take you to its dashboard and we are ready to start automating our marketing!
If you want to check that Direct Mail is working. Click on the Settings Icon in the top right, then on Email settings. There is a Green 'Test Connection' button, click this. If everything is working perfectly you will get a success message.
<Test Direct Mail in the Mautic Admin settings>
That's it! Mautic is an impressive platform that is constantly growing. Find out more here.