How to send mail from terminal in Ubuntu
There are multiple ways to send mail. Postfix is one of them.
Step 1: Install Postfix
$ sudo apt update
$ sudo apt install postfix
- Select Internet site.
- Next, You can type any domain here. we can change it later.
Step 2: Save Gmail password
Create a new file
$ sudo nano /etc/postfix/gpasswd
[smtp.gmail.com]:587 username@gmail.com:password
Step 3: Configure postfix
$ sudo nano /etc/postfix/main.cf
Add or update the properties
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/gpasswd
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
$ sudo postmap /etc/postfix/gpasswd
$ sudo systemctl restart postfix
mail -s "Subn" username@gmail.com
CC:
Enter the message
Press Ctrl + D to send message.
That's it folks.
Comments
Post a Comment