With the new “Post by Email” feature from WordPress it is super simple to post directly from Vim. All you need are:
- your “secret” email handle for your blog
- an smtp app that accepts cargo on standard input
My choice of smtp app is msmtp . Configuration is a lot simpler than trying to configure a monstrous MTA like exim.
A blast from the past
When you write a new blogpost to be sent from Vim via msmtp you have to format it as an email. i.e. Your file has to start with an email header. In the days of high-powered GUI email-clients this may be a lost artform – so here is the quick and dirty:
From: firstname.lastname@example.org To: email@example.com Subject: The headline of your post goes here
Important: There must be 2 linefeeds between the “Subject” line and the body of your post.
Once you have finished your oeuvre you can simply “write” it to msmtp with
:w ! msmtp -t -a yourmailaccount. The
-t switch makes msmtp read the recipient from the “To:” line of the header. The
-a switch tells msmtp to send the email via the server specified under yourmailaccount in its runcontrol file (.msmtprc).