2

I'm trying to configure msmtp (on Ubuntu 12.04). When I'm trying to send an email, it "hangs" (well, ctrl-c aborts it, so it's not really a hang, but it seems not to do anything anyway). Here's my .msmtprc (here and further the password and all addresses are correct, of course):

account wmi

host smtp.wmi.amu.edu.pl
port 465
auth on
user mbork
password ***
from from@address

account default : wmi

When I invoke cat mailtest.txt | msmtp -v to@address, I get this:

ignoring system configuration file /etc/msmtprc: Nie ma takiego pliku ani katalogu
loaded user configuration file /home/marcin/.msmtprc
falling back to default account
using account default from /home/marcin/.msmtprc
host                  = smtp.wmi.amu.edu.pl
port                  = 465
timeout               = off
protocol              = smtp
domain                = localhost
auth                  = choose
user                  = mbork
password              = *
passwordeval          = (not set)
ntlmdomain            = (not set)
tls                   = off
tls_starttls          = on
tls_trust_file        = (not set)
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                  = from@address
dsn_notify            = (not set)
dsn_return            = (not set)
keepbcc               = off
logfile               = (not set)
syslog                = (not set)
aliases               = (not set)
reading recipients from the command line

and nothing happens.

(The file mailtest.txt looks like this:

To: to@address
From: from@address
Subject: A test

msmtp testing

)

What might cause this problem?

mbork
  • 201
  • Man for msmtp says -v is ignored. Try -d for debug msgs. What happens if you enter a line of text and hit Enter? – Chris Good Dec 30 '12 at 09:16
  • @Chris: nothing seems to happen... – mbork Dec 30 '12 at 17:59
  • @ChrisGood: And now I checked, and in my version of msmtp -v and -d are synonymous. – mbork Dec 30 '12 at 18:30
  • Hi mbork, Sorry I must have been looking at some other version on man msmtp - I thought I was in 12.04 but Safari doesn't seem to handle Ubuntu man pages properly and I must have searched and found man entry for another version. What if you do a Ctrl-D or enter a full stop, then Enter, or enter a From: xxx@domain line? I haven't used msmtp before... why are you using that? – Chris Good Dec 30 '12 at 20:46
  • @ChrisGood: I tried giving msmtp various inputs: e.g., first headers, then an empty line, then some body, or just a body, I did Ctrl-D, etc. Nothing seems to help. And I'm using it because I want to configure mu4e to work with it (somehow I didn't manage to configure Emacs' native smtp library). – mbork Dec 31 '12 at 08:22
  • 1
    Hi mbork, Sorry I have no more suggestions. Good luck with this.. – Chris Good Dec 31 '12 at 21:09

5 Answers5

6

In my case this problem was caused because msmtp enables StartTLS by default. When StartTLS is enabled, msmtp will connect to the server and wait for the server to send data (the SMTP welcome message). If the server does not support StartTLS and expects the connection to be encrypted with SSL from the beginning, it will not send data and will wait for the client to set the SSL connection up.

So you can try setting tls_starttls off in the defaults section of ~/.msmtprc. Also check that the port is correct.

(To troubleshoot this problem, I verified with strace msmtp that when msmtp was hanging it was connecting to the right server on the right port and waiting to receive data, whereas using openssl s_client on the same server and port seemed to work.)

a3nm
  • 423
4

Beware! "reading recipients from the command line" is the last informational message from msmtp before it tries to connect to the server. If it hangs at that point, it means it can't connect. Nothing to do with the command line so don't do what I did and go off on wild goose chases. You could try connecting with telnet (e.g. telnet mail.example.com 587) to see if the server responds. If not, double check its url and port. Or, in my case, fail2ban on the server had banned me after some failed login attempts due to a wrong user name. Simple answer in that case is to wait several hours for the ban to expire.

2

OK, problem solved. msmtp version 1.4.26 seems to be broken; after installing v1.4.30 it started to work.

mbork
  • 201
0

Scaleway blocks the typical SMTP ports by default - 25, 465, 587 which resulted in this same log results.

Their docs show how to enable the SMTP access, archived from their website 2022-01-06 [0]:

You can enable them from the security group configuration.

Requirements:

  • You have an account and are logged into the Scaleway Console
  • You have created at least one Instance
  • You have a Build Level account
  • You have completed the identification process (KYC)
  1. Click Instances on the side menu of the Scaleway console.

  2. Click the Security Groups tab.

  3. Select the security group for which you want to enable SMTP ports. Note: If you have not created any security groups, your Instance has been assigned to the default security group, so this will be the one you should modify.

  4. Tick the checkbox Enable SMTP. Note: The security group settings will be immediately updated on all your virtual Instances.

[0] https://www.scaleway.com/en/docs/console/my-account/how-to/send-emails-from-your-instance/

user1278519
  • 101
  • 2
  • Maybe your answer is 100% correct, it might also become 100% useless if that link is moved, changed, merged into another one or the main site just disappears... :-( Therefore, please [edit] your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material... – Error404 Jan 05 '22 at 10:43
0

Sorry for bringing this old thread back to life, but seeing it as 12.04 currently still is LTS it may still be of value to some.

Today I configured msmtp and ran into the same problem as OP described; the command hanging at "reading recipients from the command line". I solved the problem by adding the "port" parameter and the port used by my ISP. If no port parameter is set the default (25) is used, and my ISP uses a different port when using STARTTLS.

I see that OP already had the port parameter configured, so it might not be the issue in this particular case. However with my configuration the email was successfully sent (and received), so I don't believe msmtp 1.4.26 is broken.

rsi
  • 1