I tried self-hosting ``AnonAddy'' with Docker, which allows you to create and manage any number of throwaway email addresses for forwarding.



There are many people who, while using various services as a ``just a trial'', end up receiving a large amount of promotional emails before they know it. However, if you use a disposable email address creation service online, there are security concerns and the risk that the service may suddenly stop. 'AnonAddy' is a disposable email address creation service for forwarding, and because it is open source, it can be self-hosted. I immediately tried self-hosting using Docker.

anonaddy/docker: AnonAddy Docker image

https://github.com/anonaddy/docker

Free, Open-source Anonymous Email Forwarding - addy.io
https://addy.io/


To run AnonAddy, TCP ports 25, 8000, and 11334 must be accessible from the Internet, so change the router's firewall settings in advance.

To start AnonAddy using Docker, install Docker using the method that suits your environment from the link below.

Install Docker Engine | Docker Documentation
https://docs.docker.com/engine/install/


This time, to use Debian, I entered the following command.

[code]sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

echo \
'deb [arch='$(dpkg --print-architecture)' signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
'$(. /etc/os-release && echo '$VERSION_CODENAME')' stable' | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin[/code]



Once Docker is installed, we will prepare files for AnonAddy by referring to the examples in the official repository . First, save the following content with the name '.env'.
[code]MYSQL_DATABASE=addy
MYSQL_USER=addy
MYSQL_PASSWORD=addy[/code]



Next, create a key to use in the app with the command below.
[code]echo 'base64:$(openssl rand -base64 32)'[/code]



Then save the following content as 'addy.env'. You can check the environment variables that can be set here at ' environment-variables ' in the official repository.
[code]TZ=Asia/Tokyo
PUID=1000
PGID=1000

MEMORY_LIMIT=256M
UPLOAD_MAX_SIZE=16M
OPCACHE_MEM_SIZE=128
REAL_IP_FROM=0.0.0.0/32
REAL_IP_HEADER=X-Forwarded-For
LOG_IP_VAR=remote_addr

APP_KEY=[Enter the key you created earlier here]
APP_DEBUG=false
APP_URL=[Address when accessing AnonAddy from outside]

ANONADDY_RETURN_PATH=bounces@[domain used in email]
ANONADDY_ADMIN_USERNAME=anonaddy
ANONADDY_ENABLE_REGISTRATION=true
ANONADDY_DOMAIN=[Domain used for email]
ANONADDY_ALL_DOMAINS=[Domain used for email]
ANONADDY_HOSTNAME=mail.[Domain used for email]
ANONADDY_DNS_RESOLVER=127.0.0.1
ANONADDY_SECRET=[Random number created randomly]
ANONADDY_LIMIT=200
ANONADDY_BANDWIDTH_LIMIT=104857600
ANONADDY_NEW_ALIAS_LIMIT=10
ANONADDY_ADDITIONAL_USERNAME_LIMIT=3

MAIL_FROM_NAME=AnonAddy
MAIL_FROM_ADDRESS=anonaddy@[domain used for email]

POSTFIX_DEBUG=false
POSTFIX_SMTPD_TLS=false
POSTFIX_SMTP_TLS=false[/code]



Finally, copy and save the official sample as 'compose.yml'.

Once you have prepared the three files '.env', 'addy.env' and 'compose.yml', start AnonAddy with the command below.
[code]sudo docker compose up -d[/code]



Downloading of the necessary files will begin automatically.



After the download is complete, AnonAddy should start automatically, but the following error occurred and it stopped. Apparently port 25 is already in use.
[code]Error response from daemon: driver failed programming external connectivity on endpoint anonaddy (66c991bfec98efd4c94a758af2ad24d90892a79a1fb451920cd874949a41fbae): Error starting userland proxy: listen tcp4 0.0.0.0:25: bind: address already in use[/code]



So, install and run 'lsof' to see which app is using the port.
[code]apt install -y lsof
sudo lsof -i:25[/code]



As shown below, we found that 'exim4', which is installed by default on Debian, uses port 25.



Uninstall exim4 with the command below.
[code]sudo apt-get remove exim4-base[/code]



Run the command below again to start AnonAddy.
[code]sudo docker compose up -d[/code]



This time it started normally.



If you want to check the execution log, enter the command below.
[code]docker compose logs -f[/code]



By default, the app starts on port 8000, so access ``Set domain: 8000'' with a browser. However, when I try to access it with a browser, I cannot connect. When I check the log, it says 'ERROR: Either ANONADDY_SECRET or ANONADDY_SECRET_FILE must be defined'.



After investigating the cause, I found that when I generated a key using the command 'echo 'base64:$(openssl rand -base64 32)' and entered it into addy.env, I deleted the 'base64:' part. The problem was that When I entered the key again and restarted, I was able to access normally this time.



User registration can be done via the browser or from the command line. Let's create a user using the command below.
[code]sudo docker compose exec anonaddy anonaddy anonaddy:create-user '[username]' '[real email address]'[/code]



If the user creation is successful, the following will be displayed. The 'user_id' part is the initial password.



Log in using your registered username and initial password.



When you log in, you will be asked to verify your email address.



When you look at your mailbox, you will see an email from AnonAddy, so click 'Verify Email Address'.



'Email Address Verified Successfully' is displayed and you can now use AnonAddy. Immediately click 'Create New Alias' to create a throwaway email address.



Set the domain of the throwaway email address, email address of the throwaway email address, description, and forwarding destination, and click 'Create Alias'.



Your email address has been created. You can copy the address by clicking on it.



I'll try sending an email right away.



After a while, AnonAddy's 'EMAILS FORWARDED' count increased. The 'Forwarded' count for the email address you created earlier has also increased.



The email was successfully forwarded and sent. Since the sender's email address has been replaced with an address that goes through AnonAddy, there is no need to worry about your real email address being revealed even if you reply as is.



◆Forum now open
A forum related to this article has been set up on the GIGAZINE official Discord server . Anyone can write freely, so please feel free to comment! If you do not have a Discord account, please create one by referring to the article explaining how to create an account!

• Discord | 'How many email addresses do you have? Are you able to manage them all?' | GIGAZINE
https://discord.com/channels/1037961069903216680/1186233306782650378

in Review,   Software,   Web Service,   Web Application, Posted by log1d_ts