Skip to content

Server and client implemented in C to manage a mailing list where people can subscribe and I can send emails

Notifications You must be signed in to change notification settings

drmargarido/mailing_list

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailing Lists

With this system people can register with their email in a mailing list for the server owner later be able send any wanted email.

I built this for myself, and put it here just as an example of how a web service can be done in C. If anyone wants to use it probably you will want to edit the email templates that exist in the code.

Download Repository

Clone with submodules for the dependencies of each part

git clone --recurse-submodules git@github.com:drmargarido/mailing_list.git

Server

Functionality

  1. Allow register in a game mailing list.
  2. Send email to users to confirm that they joined the mailling list.
  3. Allow registered users to unsubscribe if they want.

NOTE: There is no endpoint to add new games to the database, it needs to be done with the create_game function that exists in the server/database.c file or with a query directly in the database.

Setup Development Process

  1. Create postgres database with name maling_list.
  2. Edit the file server/environments/dev.c with the postgres database user password.
  3. Run migrations.
psql -U postgres -d mailing_list -h 127.0.0.1 -f server/migrations/001_init.sql
psql -U postgres -d mailing_list -h 127.0.0.1 -f server/migrations/002_add_confirm.sql
  1. Install libpq.
  2. Install libcurl.
  3. Compile with make.
  4. Run the server bin/list-server.

Production Deploy

  1. Fill the files server/environments/prod.c and client/environments/prod.c with your wanted configurations.
  2. Compile the wanted binaries with the make release command.
  3. Create the user lists.
  4. Copy the server binary to the /opt/mailing_list folder.
  5. Make sure the user can execute the binaries on the /opt/mailing_list folder.
  6. Create the database mailing_list and run the following migrations.
psql -U mailing_list -d mailing_list -h 127.0.0.1 -f server/migrations/001_init.sql
psql -U mailing_list -d mailing_list -h 127.0.0.1 -f server/migrations/002_add_confirm.sql
  1. Create the user mailing_list in the database with access to the mailing_list database.
  2. Copy the systemd service to the /etc/systemd/system folder.
  3. Enable and activate the service.
  4. Edit the nginx configuration with the server domain and SSL certs and add it to the /etc/nginx/sites-available folder.
  5. Link the file to the /etc/nginx/sites-enabled/ folder and restart nginx.
  6. If we don't have the ssl certificates yet let only the port 80 part in the configuration and run the certbot.
  7. Block the 8080 port in the firewall for external requests so the internal server is not exposed.
/sbin/iptables -A INPUT -s 127.0.0.1 -p tcp --destination-port 8080 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --destination-port 8080 -j DROP
  1. Copy the cron binary to the /opt/mailing_list folder.
  2. Make sure the user lists is the owner of the cron binary.
  3. Copy the cron/mailing_list file to /etc/cron.d/mailing_list.

Dependencies

Testing

Run

  1. For now the user for testing in the database is postgres with the password 123qweasd..
  2. Run the following command:
make test

Client

functionality

  1. Consult mailing list by game.
  2. Send email to all users of a mailing list.

Dependencies

Other

A devlog about the mailing list development can be found here.

About

Server and client implemented in C to manage a mailing list where people can subscribe and I can send emails

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published