AWS Low Cost Mailing List Using phpList And SES
Written by Ian Elliot   
Tuesday, 27 September 2022
Article Index
AWS Low Cost Mailing List Using phpList And SES
Sending emails

phplistt banner

Install phpList

The next and almost final major step is to install phpList. This is easy to do as long as you can transfer files from your local machine to the new server. I usually set up WinSCP or something similar and make an SCP connection to the server.  If you are using WinSCP then select SCP as the protocol, use the AWS keyfile ppk as your authentication and select sudo su - as your shell as this gives you root access, which you will most likely need.

To install phpList go to:

https://www.phplist.org/

and download the ZIP file (or the TGZ file) unzip the file and copy the lists directory into the webserver's HTML directory, usually

/var/www/html/

The lists directory contains all of the PHP files you need to make it work. The PHP program creates the database tables you need, but you have to create the database, i.e. a schema, and a user. To do this in MySQL Workbench simply select the Create Schema icon or in a MySQL console enter:

CREATE SCHEMA myMailer

or whatever you want to call the database.

Next you need to setup a user for the phpLists program to use to  connect to the database. This is often difficult to do using MySQL Workbench because of the different security mechanisms. The simplest thing to do is use a command line:

CREATE USER 'myMailerUser'@'localhost'
IDENTIFIED BY 'password';

where you replace password by a strong password and use a different user name if you want.  This assumes that you will be connecting via SSH and are going to be treated as a local user.  Finally, you need to grant admin rights to the new user:

GRANT ALL PRIVILEGES ON *.* TO 'myMailerUser'@'%';

This is probably too much privilege, but you can worry about reducing it after getting things working. At the moment the program needs to be able to create tables.

With the database and user created we now need to tell phpLists about them. Edit the config file you will find in the config directory to read:

// what is your Mysql database server hostname
$database_host = 'localhost';
// what is the name of the database we are using
$database_name = 'myMailList';
// what user has access to this database
$database_user = 'myMailListuser';
// and what is the password to login to control the database
$database_password = 'database password';

Save the config file and leave other entries as they are. There are lots of configuration options you can adjust later.

As long as all of the details are correct you should now be able to start phpList and use it to create the tables you need. Go to:

http://mywebsite.co.uk/lists/admin

This will create the tables you need and let you set up an admin user with the default user name admin and you supply the password to be used in future.

You can start to explore phpList and discover how to setup emails and lists to send emails from. There are also features to setup web pages to get people to sign up and manage their accounts. What you need to do here depends very much on what you want to hand over to the mailing list. I decided to keep the website's existing sign up pages and migrate slowly to using phpList to manage users. You can easily import an existing user database using CSV. It is easy to export from the database in CSV format and very easy to import it.

SES

Getting the server up and running is only part of the story. We now need some way of sending emails. You can setup any SMTP server you have access to but a good solution for many users is Amazon's SES service. This lets you send build emails and as you are using an AWS server the good news is:

$0 for the first 62,000 emails you send each month, and $0.10 for every 1,000 emails you send after that.

You also have to pay for data transfer, but you can ignore this unless you are sending big attachments where you pay  $0.12 per gigabyte (GB) of data. What this means is that if you are sending fewer than 62,000 emails per month your only significant cost is the server.

To set up phpList to send via SES the simplest solution is to install the SES plugin.  Sign in to phpList, navigate to the Config menu and select Manage Plugins. Use Find Plugins to find the SES plugin. Use the installation URL, currently:

https://github.com/bramley/phplist-plugin-amazonses/archive/master.zip

to install the plugin. You also need to enable it and the CommonPlugin which it makes use of. You then need to configure the SES plugin. Use the Config, Settings menu and scroll to the section that concerns the plugin. You need to enter an AWS access key ID and the secret access key and you have to first create these using the AWS IAM service. Create an Access key specifically for phpList and use them in the phpList config. You also need to specify the SES region and the endpoint in use and these you can look up in your SES account.

With all of these pieces of information in place you still might not be able to send an email. To test this, start a new campaign and send a test message. If it isn't sent check the log and you will probably see that SES is rejecting the email due to the sender's email address not being validated. Either change the phpList configuration so that it is sending from an SES validated email or use the SES console to validate the email address you are using. Once this is achieved you will find that you can send a test email and a mailing list once you have one set up.

You can now spend time tuning and customizing your phpList setup. Make sure that you set the sending rate to fit in with your SES maximum rate. If you are not using the server to manage the mailing list you could opt to switch the machine off when it is not sending. This would reduce the hosting bill, but this is only worth doing if you don't allocate an Elastic IP EIP address to the machine. An EIP keeps your server at a fixed address and this makes life easier. It is also free, but only while the machine is running. When it is suspended the EIP not in use is charged at $0.005 USD per hour, which is $3.60 per month, which is not much less than the cost of keeping the server live 24/7 and it is actually more if you use an ARM t4g.nano. The economics of AWS are a complex mystery.

phplistaws 

More Information

https://www.phplist.org/

https://aws.amazon.com/

Related Articles

Getting Started With Azure Linux VMs

Amazon Releases Data IDE, Meet EMR Studio

Amazon AWS Invests In Rust 

AWS Greengrass Now Supports C Executables

AWS Amplify Opens Cloud Services For JavaScript

CodeStar to Simplify Development On AWS

Exploring Storage Options on AWS

AWS Improvements For Developers

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

 

Banner


Rust Foundation Announces Safety-Critical Consortium
21/06/2024

The Rust Foundation, the nonprofit organization dedicated to supporting and sustaining the Rust programming language, has announced a Safety-Critical Rust Consortium along with industry partners inclu [ ... ]



At What Age Do Programmers Write Languages?
29/05/2024

This is just one of many question that can be answered by reference to PLDB, the programming language database devised and maintained by Breck Yunits, himself the author of Scroll, an o [ ... ]


More News

C book

 

Comments




or email your comment to: comments@i-programmer.info



Last Updated ( Tuesday, 27 September 2022 )