Today I have tried mail
utility from my ubuntu system. Now in mail
command, I could not find an utility to send mail from my gmail account. In fact, it sends from some adhikarisubir@ubutu
(adhikarisubir is my login name). So wondering is it possible to send mails from my gmail account?
Also, I noticed simple mails generated from sendmail goes to junk folders in gmail; In fact rediff does not allow to accept these mails. How can I avoid this?
1 Answer
To send mail from your gmail account in Ubuntu system test this:
Open a terminal,
Press Ctrl+Alt+T
Run it:
sudo -i
apt-get update
apt-get dist-upgrade
apt-get install --reinstall msmtp-mta heirloom-mailx
apt-get clean
exit
nano ~/.mailrc
In the open file, paste these lines:
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
Ctrl+O, save file. Ctrl+X, close nano.
Continue run:
nano ~/.msmtprc
In the open file, paste these lines:
#Gmail account
defaults
logfile ~/msmtp.log
account gmail
auth on
host smtp.gmail.com
from [email protected]
auth on
tls on
tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
user [email protected]
password your_gmail_password
port 587
account default : gmail
Ctrl+O, save file. Ctrl+X, close nano.
chmod 600 .msmtprc
You can send email from the command line like this:
mail -s "subject" [email protected]
The cursor will go to a blank line.
Enter your email message.
When you're done, press Enter to go to a blank line
And then hit Control+D to end and sent your message.