marlam / msmtp

SMTP client with sendmail compatible interface
https://marlam.de/msmtp
GNU General Public License v3.0
176 stars 36 forks source link

msmtp take much time around remove_bcc_headers = on #161

Closed stacyharper closed 2 months ago

stacyharper commented 2 months ago

I'm investigating a bit why sending email take ~3s. Here the log using a relative ts output. Dunno how much the output is buffered, and so if the result is usefull. But we see that l.44 took 2s to output.

https://paste.sr.ht/~stacyharper/894beb86d5b06b8072f992c3d8a7ab05d7d53c08

Example:

$ time msmtp --read-envelope-from contact@willowbarraco.fr <<EOF
From: Willow Barraco <contact@willowbarraco.fr>
Subject: test

Coucou?
EOF

real    0m2.943s
user    0m0.035s
sys 0m0.022s

Here my ~/.msmtprc: https://paste.sr.ht/~stacyharper/3d11053db1c186ad9304c7a4e64bbc08fc93769b

Any clue on how to improve this situation?

marlam commented 2 months ago

That's your network. You can see that msmtp uses almost no CPU in comparison to the total time spent. I don't know what this 'timer' command is but I think you are interpreting it wrong.

You can verify by sending to something dumb at localhost.

Use this as your SMTP server:

msmtpd --interface=::1 --port=12345 --auth='testuser,echo testpassword' --command='cat; echo'

Then run msmtp like this:

time msmtp --host=::1 --port=12345 --auth=plain --user=testuser --passwordeval="echo testpassword" --read-envelope-from  recipient@example.com < input

The output on my machine:

real    0m0.101s
user    0m0.009s
sys     0m0.004s

Still some time going into network overhead, even to localhost, but you can see the difference.