Hi all,
Distro: Pop! OS 19.10
Complete error line:
Code:
sendmail: cannot log to /home/javierdl/msmtp.log: cannot open: Permission denied
I am trying to send Gmail emails from Terminal.
I started by following these instructions: "How to use Gmail from the Ubuntu Terminal to send Emails"
Steps Summary:
1. Installed msmtp-mta
2. Configured the msmtprc file for Gmail by adding this lines:
Code:
#Gmail account
defaults
#change the location of the log file to any desired location.
logfile ~/msmtp.log
account gmail
auth on
host smtp.gmail.com
from <yourmail@gmail.com>
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
user <yourmail@gmail.com>
password <your-password>
port 587
#set gmail as your default mail server.
account default : gmail
3. Secured the msmtprc file with this:
4. Installed heirloom-mailx
5. Configured the .mailrc file:
Code:
set sendmail="/usr/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
I have also tried this alternative, from: How to Send Email from mailx Command in Linux Using Gmail's SMTP
Code:
set smtp-use-starttls
set ssl-verify=ignore
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=sender@gmail.com
set smtp-auth-password=$EMAIL_ACCOUNT_PASSWORD
set from="sender@gmail.com(sender name)"
Command lines I have tried, to send:
1.
Code:
echo "Subject: hello" | sendmail recipientmail@gmail.com
sendmail: cannot log to /home/javierdl/msmtp.log: cannot open: Permission denied
sendmail: log info was: host=smtp.gmail.com tls=on auth=on user=sender@gmail.com from=sender@gmail.com recipients=recipientmail@gmail.com mailsize=82 smtpstatus=250 smtpmsg='250 2.0.0 OK 1582300328 c52sm1750529qtb.16 - gsmtp' exitcode=EX_OK
2.
Code:
mail -s "test" "recipientmail@gmail.com"
testing
EOT
send-mail: cannot log to /home/javierdl/msmtp.log: cannot open: Permission denied
send-mail: log info was: host=smtp.gmail.com tls=on auth=on user=sender@gmail.com from=sender@gmail.com recipients=recipientmail@gmail.com mailsize=245 smtpstatus=250 smtpmsg='250 2.0.0 OK 1582300350 x28sm1637814qkx.104 - gsmtp' exitcode=EX_OK
^C
Just in case I stopped apparmor to test it
Code:
sudo systemctl stop apparmor
But still made no difference
I also tried owning the msmtprc file (source):
Code:
sudo chown my_username ~/.msmtprc
Additionally I created a msmtprc directory in /etc/ (as it did not exist) and owned it too:
Code:
sudo chown my_username /etc/msmtprc
I rebooted the computer, and still no go
Maybe Gmail is not treating the involved apps as secure applications. I went to my Gmail account to change the Less Secure Applications Access Settings. But when choosing the purpose of the password, I suppose I choose Mail, and for device Linux computer? I thought I had to be more specific than this. Like, providing the name of the actual app that will be needing the authorization, like msmtp-mta, or mailx. Source: search for "ssmtp: Authorization failed"
Bookmarks