Results 1 to 4 of 4

Thread: SendMail Error: Permission Denied :(

  1. #1
    Join Date
    Dec 2009
    Beans
    433

    Question SendMail Error: Permission Denied :(

    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:
    Code:
    chmod 600 .msmtprc
    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"
    Last edited by javierdl; February 21st, 2020 at 07:02 PM.

  2. #2
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: SendMail Error: Permission Denied :(

    Thread moved to System76 Support.

  3. #3
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: SendMail Error: Permission Denied :(

    Does the service run as a user other than root? What does "account gmail" mean? Is that the username that owns the msmtp process?

    If so, you should probably be writing logs in /home/gmail rather than some other home directory..
    If you ask for help, do not abandon your request. Please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  4. #4
    Join Date
    Dec 2009
    Beans
    433

    Re: SendMail Error: Permission Denied :(

    Code:
    sendmail: cannot log to /home/javierdl/gmail/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=recipient@hotmail.com mailsize=82 smtpstatus=250 smtpmsg='250 2.0.0 OK  1582388185 i5sm3326029qtq.12 - gsmtp' exitcode=EX_OK
    Screenshot from 2020-02-22 11-22-51.png

    I also had myself for Group before, now I was trying adm, but still no go . (This text to the left was an hour ago, but I just tried "sudo" for Group too, and when setting up the command line to send, I did use sudo, but to no avail still).

    Maybe I should just omit that field in the script (?). After all, the messages are going through.
    Last edited by javierdl; February 22nd, 2020 at 06:30 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •