pages tagged Msmtphroy.euhttps://hroy.eu/tags/Msmtp/hroy.euikiwiki2023-10-30T21:00:42Zhttps://hroy.eu/tips/mutt/delaySending/2018-10-29T20:32:52Z2014-12-21T15:20:45Z
<p><strong>Edit</strong>: You should have a look at <a href="https://github.com/parisni/msmtp-queue-defer">msmtp-queue-scheduler</a> to solve this :-)</p>
<p>Thanks Nicolas!</p>
<hr />
<p>I've been looking for a solution to this problem:</p>
<p>Sometimes, I just sent an email, and after 10 seconds I realise: “Oh,
damn, I forgot to add something!” or “Oh, nooooes, I sent it to the
wrong person!” Whatever. This is annoying.</p>
<p>Making mistakes is human. Email clients are for humans, therefore they
should be able to cope with our mistakes and help fix them. That's why
software should allow us to “undo” or “cancel” our actions.</p>
<p>Gmail does this right, so why can't we do it in Mutt too?</p>
<p>I wrapped my head around this a little bit. And I'm no programmer, so
after trying to add some stuff here and there, I finally decided to
have it with this very, very, very dirty hack. You've been warned. So
here's how I do it:</p>
<ul>
<li><p>I use the <code>msmtpq</code> script which allows me to queue emails when I'm
offline, so that <code>msmtp</code> can take care of sending queued email
when I'm back online.</p></li>
<li><p>I have tried to put a delay of 30 seconds any time before calling
<code>msmtp</code> or I tried to force <code>msmtpq</code> to queue all outgoing email
for at least 30 seconds. But I couldn't make it work. So instead,</p></li>
<li><p>I added <code>sleep 30 &&</code> at the beginning of the <code>msmtpq</code> script!</p></li>
<li><p>Result: now when I send an email, I have 30 seconds to realise
when I made a mistake. Then, I just need to activate plane mode on
my laptop, and fix whatever needs fixing from here.</p>
<p>One issue with this workflow is that I can't just edit the
outgoing email, I also have to make sure I update the openPGP
signature. So I'd probably just delete the email and start again
from Mutt.</p></li>
</ul>
<p>I warned you, this is very ugly :-)</p>
<p>But as they say: the best way to get an answer on the net is not to
ask a question, but to give the wrong answer!</p>
<p>So if anyone wants to implement this feature in <code>msmtpq</code>, that would
be great. Here's how it could work ideally, in the <code>.muttrc</code>:</p>
<pre><code>set sendmail="msmtpq --wait 30"
set sendmail_wait=-1 #send in the background
</code></pre>
<p>then <code>msmtpq</code> could queue the email for 30 seconds before testing the
connection and feeding the email to <code>msmtp</code>. The Queue management
could then allow the user to pause all outgoing emails, cancel the
email containing the mistake, then sending remaining emails from the queue.</p>
<p>The <code>msmtpq</code> script is available at: <a href="http://sourceforge.net/p/msmtp/code/ci/master/tree/scripts/msmtpq/">http://sourceforge.net/p/msmtp/code/ci/master/tree/scripts/msmtpq/</a></p>
WTF Sunday: couldn’t send email with msmtp any more. Culprit: the lockdirhttps://hroy.eu/posts/msmtpq-lock/2023-10-30T21:00:42Z2014-08-04T09:01:17Z
Yesterday, I spent some hours trying to understand what the fuck was wrong with my email setup. Indeed, I could not send email any more even though every time I hit mutt replied to me: even though it clearly wasn’t!<hr><br><p>Yesterday, some of the strangest thing happened. I couldn’t send
email any more!</p>
<p>The real problem was that I got no error feedback. Actually I haven’t
been able to send email since August 1, but I had not realised! I
thought everything was entirely fine. Until I was online discussing some
issue with Torsten and he kept waiting for my emailed answer. After two
hours: still no reply from me.</p>
<p>So, something was wrong. But what?</p>
<p>First, I tried with many different SMTP servers (my own server, or
FSFE’s server which both use <a href="http://kolab.org">Kolab</a> but
then I also tried with OIN’s server) and the result was always the same:
I couldn’t send email. Clearly, the problem was local.</p>
<p>Was it mutt? I use an experimental fork of mutt, called mutt-kz… I
tried to see the result of the debug file, but there was nothing really
interesting in it. Then I tried with using mutt’s builtin sending email
feature and I got:</p>
<pre><code>La session SMTP a échoué : 554 5.7.1 Service unavailable; Client host [46.115.137.139] blocked using zen.spamhaus.org; http://www.spamhaus.org/query/bl?ip=46.115.137.139</code></pre>
<p>Right now, I rely on an UMTS connection at home. Maybe that was the
problem? But no, using FSFE’s VPN led to the same awkward result!</p>
<p>At this stage, I was completely clueless.</p>
<hr />
<p>Maybe the problem was because of the program I use to connect to my
SMTP servers: msmtp. Actually, I use the scripts that allow me to queue
email before sending it (very useful on a laptop). But unfortunately,
whether I relied on msmtp or msmtpq in the mutt config, the same result
occurred: mutt told me “Email sent” even though no email was sent (I
even tried, when disconnected from the internet, the same result
occurred!!)</p>
<p>Today by trying msmtpq manually, I finally got this:</p>
<pre><code>hrd@xps ~/.msmtpqueue (git)-[annex/direct/master] % cat email.mail| msmtpq -a ampoliros
cannot use queue /home/hrd/.msmtp.queue : waited 240 seconds for
lockdir [ /home/hrd/.msmtp.queue/.lock ] to vanish ; giving up
if you are certain that no other instance of this script
is running, then 'rmdir' the lock dir manually</code></pre>
<p>Hurray!</p>
<p>There must be some better way to handle this! My first impression is
that feedback between msmtpq and mutt should be better dealt with, so
that I don’t get “Email sent” while msmtpq is actually hanging!</p>
<p>I’m not sure where to file this bug report:</p>
<h4 id="replicate-the-bug">Replicate the bug:</h4>
<ol type="1">
<li><p>Have a unusable <code>.lock</code> directory in your msmtp queue
(I have no idea how I did that)</p></li>
<li><p>Send an email with Mutt</p>
<p>Get “Email sent”</p></li>
<li><p>msmtpq is actually not handling the email at all, not adding it
to the queue (msmtp-queue says there’s no email in the queue) and not
sending it to msmtp</p></li>
</ol>
<h4 id="expected-behaviour">Expected behaviour:</h4>
<ol type="1">
<li><p>Have a unusable <code>.lock</code> directory in your msmtp queue
(I have no idea how I did that)</p></li>
<li><p>Send an email with Mutt</p>
<p>Get an error feedback</p></li>
<li><p>Suggest to delete the lockdir</p></li>
</ol>
<hr />
<p>It’s very hard to see which program should be improved here. When
using msmtpq scripts, the README tells me to add this in mutt:</p>
<pre><code>set sendmail_wait = -1 #send in the background</code></pre>
<p>So I assume that whatever I do, mutt will now always tell me “Email
sent”. Isn’t there a better way?</p>