Send Mail Using Gmail using Command Line
Yeah, you can send mail from your gmail account using command line.
Requirements
You have two options here.
Gmail account settings
Either enable less secure apps in your Google account or Generate an app password.
Tools being used
For Arch Linux:
|
|
For Debian, Ubuntu and other Debian derived distributions:
|
|
For Fedora, CentOS, Redhat etc:
|
|
Encrypt password
Using gpg
, we are going to encrypt our password. I have a detailed video tutorial on gpg
if you’re interested.
|
|
Now enter the password for your gmail from first step. Once done, enter Ctrl + D
.
Configure msmtp
Paste this into ~/.msmtprc
or if you want msmtp
system wide so any user on this system can use this gmail account to send mails, copy it to /etc/msmtprc
.
|
|
Replace your_gmail_address
with your gmail address.
Voila.
Send a test mail
We are done now. Just send a test mail now.
|
|
Use with mutt
You can use this msmtp
setup with mutt
which is suck less mail client and runs in a terminal.
I have a detailed video tutorial on mutt
here.
Thanks for reading.