I use an email client called Alpine. Currently I start it in one of several different modes in order to specify the outgoing SMTP server based on what I'm doing, in particular the From address that I wish to use.

What would be much more convenient is if I could simply direct Alpine to use my own SMTP server (on my laptop), which in turn would choose a relay server based on the From address of each message I'm sending.

I am hoping someone is already doing this (it seems like it should be a common need given recent tightening of restrictions on accepting mail) and that it is not complicated.

(As a bonus, I'd also like to be able to start Alpine in a mode which uses a local server that waits until Monday morning to send out messages.)

Here is possibly the same question: Changing SMTP authentication in mutt based on From e-mail address, but it is old and so are references on esmtp – I'm not sure esmtp is up to date with modern security protocols, etc.

  • At the risk of possibly splitting this question in two, I cannot find out how to call a server like esmtp from Alpine, ie instead of giving it a remote server address, etc, I want to spawn a local process (each email?? Or do I run esmtp once?) – CPBL Jul 9 at 17:42

Answer for Alpine email client

Recent versions of Alpine are compiled for Ubuntu with many of the available patches, i.e., enhancements, and these include a feature called "smtp-rules". It's not perfectly well documented, but here is what the .pinerc section looks like for me. It handles email addresses from my employer, from my alma mater, and from two Gmail identities:

# Unfortunately, using gmail's SMTP servers require setting up 2-factor authorization,
# which then allows you to get an "app password" for each account, which can be used
# by Alpine. Instead of doing this, for now I'm using MIT's, which is changing but
# currently letting through my gmail identities
smtp-rules= _FROM_ == {me@McGill.ca} => _SMTP_{smtp.office365.com:587/tls/user=me@mcgill.ca}
smtp-rules= _FROM_ == {someone@gmail.com} => _SMTP_{outgoing-alum.mit.edu:465/ssl/user=me}
smtp-rules= _FROM_ == {anotheridentity@gmail.com} => _SMTP_{outgoing-alum.mit.edu:465/ssl/user=me}
smtp-rules= _FROM_ == {me@alum.mit.edu} => _SMTP_{outgoing-alum.mit.edu:465/ssl/user=me}

For other clients, or another way using Alpine

I haven't tested esmtp, since the above works nicely, but this seems to be an alternative:

  1. Install esmtp

  2. Set the smtp-server field to the executable, /usr/local/bin/esmtp

  3. Put something like the following in your ~/.esmtprc file:

    identity joe@mail.com
        hostname mail.server.com:25
        username "joe"
        password "secret"
        starttls enabled
    identity joe@gmail.com
        hostname smtp.gmail.com:587
        username "joe@gmail.com"
        password "secret2"
        starttls required

Reference for the esmtp part: Send mail with eSMTP for a simple, single-user system - TechRepublic.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.