WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [SOLVED] Configuring mailx, msmtp and gmail  (Read 13833 times)

Offline suxi

  • Newbie
  • *
  • Posts: 25
[SOLVED] Configuring mailx, msmtp and gmail
« on: September 23, 2012, 06:58:53 AM »
Hello Forum!

Browsing through the few mail threads about sending emails from a script I have concluded that mailx and msmtp should be a good solution for Tiny Core.

I have installed both extensions and last night I actually managed to establish a connection from msmtp to google. This is what I did:

I copied the Equifax_Secure_CA.pem from here -> http://www.andrews-corner.org/mutt.html to here -> /home/tc/.certs/Equifax_Secure_CA.pem

I created a basic msmtp config file with user rw only perrmissons here -> /home/tc/.msmtprc

And now I am quite proud to actually be able to do this:

Code: [Select]
tc@suxi:~$ msmtp --debug --from=myaccount@gmail.com destination@mail.com
ignoring system configuration file /usr/local/etc/msmtprc: No such file or directory
loaded user configuration file /home/tc/.msmtprc
account chosen by envelope from address myaccount@gmail.com: provider
using account provider from /home/tc/.msmtprc
host                  = smtp.gmail.com
port                  = 25
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = choose
user                  = myaccount@gmail.com
password              = (not set)
passwordeval          = (not set)
ntlmdomain            = (not set)
tls                   = on
tls_starttls          = on
tls_trust_file        = /home/tc/.certs/Equifax_Secure_CA.pem
tls_crl_file          = (not set)
tls_fingerprint       = (not set)
tls_key_file          = (not set)
tls_cert_file         = (not set)
tls_certcheck         = on
tls_force_sslv3       = off
tls_min_dh_prime_bits = (not set)
tls_priorities        = (not set)
auto_from             = off
maildomain            = (not set)
from                  = myaccount@gmail.com
dsn_notify            = (not set)
dsn_return            = (not set)
keepbcc               = off
logfile               = /home/tc/.msmtp.log
syslog                = (not set)
aliases               = (not set)
reading recipients from the command line
<-- 220 mx.google.com ESMTP bc2sm7070664wib.0
--> EHLO localhost
<-- 250-mx.google.com at your service, [xxx.xxx.xxx.xxx]
<-- 250-SIZE 35882577
<-- 250-8BITMIME
<-- 250-STARTTLS
<-- 250 ENHANCEDSTATUSCODES
--> STARTTLS
<-- 220 2.0.0 Ready to start TLS
TLS certificate information:
    Owner:
        Common Name: smtp.gmail.com
        Organization: Google Inc
        Locality: Mountain View
        State or Province: California
        Country: US
    Issuer:
        Common Name: Google Internet Authority
        Organization: Google Inc
        Country: US
    Validity:
        Activation time: Fri Nov 18 01:57:17 2011
        Expiration time: Sun Nov 18 02:07:17 2012
    Fingerprints:
        SHA1: F3:92:AE:B4:28:FE:64:03:6F:E1:55:ED:71:9E:5F:F6:88:90:5A:57
        MD5:  27:71:5C:5E:A7:D5:2B:03:9E:2F:7E:7E:1A:1B:75:A9
--> EHLO localhost
<-- 250-mx.google.com at your service, [xxx.xxx.xxx.xxx]
<-- 250-SIZE 35882577
<-- 250-8BITMIME
<-- 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2
<-- 250 ENHANCEDSTATUSCODES
password for myaccount@gmail.com at smtp.gmail.com:
--> AUTH PLAIN AG1hcmMuc3V4ZG9yZkBnbWFpbC5jb20AZ21haWwxMjM=
<-- 235 2.7.0 Accepted
--> MAIL FROM:<myaccount@gmail.com>
<-- 250 2.1.0 OK bc2sm7070664wib.0
--> RCPT TO:<destination@mail.com>
<-- 250 2.1.5 OK bc2sm7070664wib.0
--> DATA
<-- 354  Go ahead bc2sm7070664wib.0

Unfortunately now I am stuck and I didn't find any "easy read" about mailx configuration. Do I have to create a mailx configuration file? Why do I need mailx in the first place? Can't I somehow tune msmtp to continue with process of sending a mail? I tried to enter some smtp commands after google's last <-- 543 Go ahead answer but that didn't work.

When I issue a  mailx comand with basic parameters the command just gets stuck. I don't get any output whatsoever. I didn't find anything about a mailx debug mode and I also don't understand how mailx communicates with msmtp and whether and how this needs to be configured.

As always thank you for your help. A few weeks ago I didn't know a thing about Linux and thanks to Tiny Core and this Forum I am really getting into this :)

Best wishes

suxi

EDIT:

I finally found this article, which explaines my missing puzzle piece. And now it works like a charm!

I just had to create the following mailx config file: /home/tc/.mailrc

Code: [Select]
# gmail account (default)
# $ mailx -s "subject line" -a /path/attachment recipient@email.com < /path/body.txt
set from="YOURNAME@gmail.com (YOURNAME)"
set sendmail="/usr/local/bin/msmtp"
set message-sendmail-extra-arguments="-a gmail"
« Last Edit: September 23, 2012, 02:02:25 PM by suxi »

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: [SOLVED] Configuring mailx, msmtp and gmail
« Reply #1 on: September 23, 2012, 02:45:16 PM »
Ok, I am still having a problem:

If mailx gets executed from within a cron script, I get a permission error (I think this is what it is):

Code: [Select]
postdrop: warning: mail_queue_enter: create file maildrop/245267.24921: No such file or directory
Any ideas on this?

Thanks a lot

suxi

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11246
Re: [SOLVED] Configuring mailx, msmtp and gmail
« Reply #2 on: September 23, 2012, 05:00:47 PM »
Hi suxi
Just a guess on my part, but I think it might be failing because there's no  maildrop  directory, or it can't find
it the way you are running it as a cron job.

Offline suxi

  • Newbie
  • *
  • Posts: 25
Re: [SOLVED] Configuring mailx, msmtp and gmail
« Reply #3 on: September 24, 2012, 07:05:47 AM »
Hi Rich

I got it, I had to also create the .msmtprc and .mailrc config files under /root, which is where mailx and msmtp look when executed as root.

Best wishes

suxi