View previous topic :: View next topic |
Author |
Message |
AgenT Apprentice
Joined: 18 May 2003 Posts: 280
|
Posted: Sun Feb 01, 2004 3:07 am Post subject: Mutt & Multiple Outgoing (SMTP) Server Support |
|
|
My guess is this has been answered somewhere, but after reading for hours I just cannot find a good answer. Here is what I need:
I use mutt, which does not have its own smtp built in, therefore I must use an external program. I have used ssmtp and nbsmtp before, but now I must have the ability to have mutt specify (using hooks) what smtp server to use. I have no problem using a hook and changing the sendmail="" options, but the problem is I have no idea what smtp program to use! A requirement is that this smtp program must accept both with and without username/password login authentication. Notice that ssmtp cannot have more than one smtp since only one can be specified as mailhost, and nbsmtp cannot login using username/password. I am currently trying to configure postfix, but this is very confusing and I do not need any of the huge amount of advanced features. Not to mention that it is confusing me as to how I can configure it to have mutt tell it to use a specific smtp server.
[EDIT: Solution(s) below.]
Last edited by AgenT on Sun Feb 01, 2004 4:28 pm; edited 1 time in total |
|
Back to top |
|
|
AgenT Apprentice
Joined: 18 May 2003 Posts: 280
|
Posted: Sun Feb 01, 2004 4:27 pm Post subject: |
|
|
Okay, here is a "hacked" job of a fix for this (being able to use more than one different smtp server):
First, install ssmtp, become root (su) and configure the config file in /etc/ssmtp/ssmtp.conf. After this, make sure it works in mutt. If it works, copy this ssmtp.conf to a different file name like ssmtp_t1.conf. This will be your template. Make as many as needed and configure them as needed (change your mailhost, etc.). Your /etc/ssmtp/ will look like this:
Code: | ssmtp.conf
ssmtp_t1.conf
ssmtp_t2.conf
<etc> |
Now chmod the main config file like so:
Code: | chmod 0666 /etc/ssmtp/ssmtp.conf |
What you want is read/write access to the above. You are now done with configuring ssmtp.
Now edit your ~/.muttrc file. This will be different depending on what you want, but here is how I have it setup.
I use folder-hook to change my ssmtp file depending on what folder I am viewing. So for example, my private folder will use a different ssmtp template than my whatever folder(s).
Here is the proper way to have a folder-hook setup (we will add the ssmtp-specifics later): Code: | folder-hook . \
'set record="~/.maildir/private/.sent" ;\
set sendmail="/usr/sbin/ssmtp -v -d3 -au myusername -ap mypassword" ;\
my_hdr From: myfromemailaddress' |
The most important thing about this hook is that the last entry, the my_hdr, does not use any quotes. This is important so make sure that your last entry is one which is not supposed to (or at least does not have to) use quotes like my_hdr.
Here is the code which will be added to the last entry to make it choose a specific ssmtp template:
Code: | my_hdr From: myfromemailaddress`cat /etc/ssmtp/ssmtp_t1.conf > /etc/ssmtp/ssmtp.conf`' |
The above will copy the contents of the file ssmtp_t1.conf (which is our template) into ssmtp.conf, which is the config file ssmtp uses (note that those are not single quotes, but the ` which is to the left of your 1 key). Of course you will want to match your username/password (if those are needed) with the ssmtp info in the template. Also notice that this works because the my_hdr thinks that the code within `` has something to do with the header, but it does not and, after the copy of header is done, returns empty. Notice that it will probably not return empty if there is an error in the cat process.
You will also want to do this for every folder-hook (and you also want a folder-hook for every folder), so that you will always get the correct ssmtp template to load. |
|
Back to top |
|
|
dkaplowitz Guru
Joined: 22 Nov 2003 Posts: 596 Location: Philadelphia, PA
|
Posted: Sun Feb 08, 2004 10:31 pm Post subject: |
|
|
Thanks for posting your fix. I'm curious to know, however, if it's true that one can't use nbsmtp with multiple outgoing addresses. I'm trying to figure that one out now. If I hear of anything I'll post it back here. _________________ http://dkap.info |
|
Back to top |
|
|
AgenT Apprentice
Joined: 18 May 2003 Posts: 280
|
Posted: Sun Feb 08, 2004 11:08 pm Post subject: |
|
|
Do you mean having different from addresses? You can:
Code: | nbsmtp -d domain -f from@addr -h host [-p port] [-l debuglevel] |
My problem was that you cannot use nbsmtp to authenticate using username/password (notice there is nothing in the above about a username or password). Hence it was useless for the smtp server that requires username/password authentication. |
|
Back to top |
|
|
dkaplowitz Guru
Joined: 22 Nov 2003 Posts: 596 Location: Philadelphia, PA
|
Posted: Mon Feb 09, 2004 12:54 pm Post subject: |
|
|
AgenT wrote: | Do you mean having different from addresses? You can:
Code: | nbsmtp -d domain -f from@addr -h host [-p port] [-l debuglevel] |
My problem was that you cannot use nbsmtp to authenticate using username/password (notice there is nothing in the above about a username or password). Hence it was useless for the smtp server that requires username/password authentication. |
I thought you were talking about whether one could use:
usera@domainA.com, or
userb@domainA.com, or even
userc@domainB.com, etc., etc.
and specify in mutt which one you wanted to send/reply as. For instance, I have a mail account only for use with mailing lists. That's the one I want to send mail as when replying to mailing lists. There is another account that I use for personal mail, etc. So I want to be able to specify which one. _________________ http://dkap.info |
|
Back to top |
|
|
AgenT Apprentice
Joined: 18 May 2003 Posts: 280
|
Posted: Mon Feb 09, 2004 2:29 pm Post subject: |
|
|
My problem was much worse. I needed to use (that is, connect to) two different smtp servers, both having different ways of authenticating. Your problem can be easily solved within and I recommend you use ssmtp for your smtp mail sender.
What you want is to folder hooks (in your muttrc). So for example, have a folder hook for your mail list with a specific my_hdr (which would include the FROM: field) and have another folder hook for your personal mail, etc. Here are a few sites to check out:
http://www.mutt.org/
http://linuxbrit.co.uk/mutt/
http://mutt.blackfish.org.uk/
The first one is you best bet. It has a lot of information. Also, you can just look at the man page for muttrc: |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|