SMTP_ubuntu.
md 2024-10-15
Steps for installation:
Step1: Install postfix(MTA agent) and mailx(Use for commands and act as a service):
apt install postfix mailutils
The following window will then appear.
Select the internet site and click on ok.
The next will appear which will show.
Set the localhost name of the machine or by default it is set. Click on OK and it will continue to install.
Step2: Now move to the postfix configuration directory and open the file main.cf where we have to
make changes.
cd /etc/postfix/main.cf
1/3
SMTP_ubuntu.md 2024-10-15
Step3: Provide the below lines into it.
Add the host configuration lines into it. If present then edit.
relayhost = [smtp.gmail.com]:587
myhostname= your_hostname
Provide the below line at the end of the file which shows the sasl password file location. Location
of sasl_passwd we saved.
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
Enables SASL authentication for postfix
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
Step4: Create a file under /etc/postfix/sasl
Filename: sasl_passwd
Step5: Add the below line
[smtp.gmail.com]:587 <[email protected]>:<password>
Note: Try to use application password from google.
Step6: Convert the sasl_passwd file into db file.
postmap sasl_passwd
Step7: Start and enable the postfix service.
systemctl enable --now postfix.service
Step8: Allow the SMTP to be done from firewall.
ufw allow 25
Step9: Also check the SMTP server is running using command.
telnet localhost 25
To exit from the telnet use quit.
2/3
SMTP_ubuntu.md 2024-10-15
3/3