Sending a mail with smtp on localhost in ubuntu?

1.8k Views Asked by At

root@sourav-HP-Pavilion-dv6500-Notebook-PC:/var/log# echo -e "Subject: Test Mail\r\n\r\n This is my first test email." | msmtp --debug --from=default -t [email protected]

loaded system configuration file /etc/msmtprc

ignoring user configuration file /root/.msmtprc: No such file or directory

falling back to default account

using account default from /etc/msmtprc

host = smtp.gmail.com

port = 587

proxy host = (not set)

proxy port = 0

timeout = off

protocol = smtp

domain = localhost

auth = choose

user = [email protected]

password = *

passwordeval = (not set)

ntlmdomain = (not set)

tls = on

tls_starttls = on

tls_trust_file = /etc/ssl/certs/ca-certificates.crt

tls_crl_file = (not set)

tls_fingerprint = (not set)

tls_key_file = (not set)

tls_cert_file = (not set)

tls_certcheck = on

tls_min_dh_prime_bits = (not set)

tls_priorities = (not set)

auto_from = off

maildomain = (not set)

from = default

add_missing_from_header = on

add_missing_date_header = on

remove_bcc_headers = on

dsn_notify = (not set)

dsn_return = (not set)

logfile = /var/log/msmtp.log

syslog = (not set)

aliases = (not set)

reading recipients from the command line and the mail

msmtp: cannot connect to smtp.gmail.com, port 587: Connection timed out

msmtp: could not send mail (account default from /etc/msmtprc)

root@sourav-HP-Pavilion-dv6500-Notebook-PC:/var/log#

I am trying different servers for past 3-4 hours and none of them seems to work fine for me.This one did showed some output which I think can be helpful to debug it. Do you see any setting missing or wrongly configured.

1

There are 1 best solutions below

0
On

Do not you have to get an application password ?

I write gmail 'password' in msmtprc. I get error below.

msmtp: authentication failed (method PLAIN)
msmtp: server message: 535-5.7.8 Username and Password not accepted. Learn more at
msmtp: server message: 535 5.7.8  https://support.google.com/mail/?p=BadCredentials k123-v6sm24743490pga.21 - gsmtp
msmtp: could not send mail (account gmail from /home/miwa/.msmtprc)

I setup application pasword (access to URI in error message), then I can send mail to Gmail.

I use msmtp version. (on ArchLinux)

% msmtp --version
msmtp version 1.6.8
Platform: x86_64-pc-linux-gnu
TLS/SSL library: GnuTLS
Authentication library: GNU SASL
Supported authentication methods:
plain scram-sha-1 external gssapi cram-md5 digest-md5 login 
IDN support: enabled
NLS: enabled, LOCALEDIR is /usr/share/locale
Keyring support: Gnome 
System configuration file name: /etc/msmtprc
User configuration file name: /home/miwa/.msmtprc

Copyright (C) 2018 Martin Lambers and others.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.