# I want to set up an MTA

## Etal

Hi all,

I currently have a mail system which I like and works pretty well, but I can't do local mail (e.g. me@localhost) without it being sent over the internet back and forth.

The current setup consists of fetchmail as a cronjob to get all my mail, procmail to sort it and msmtp to send it. I would like to replace msmtp with something that allows me to send mail through SMTP (to gmail or other accounts that I have, based on the "From:" address) - which is what msmtp does, and also lets me use local mail (for instance, forward root's mail into my user account's procmail) without the need for Internet. Other than that, I don't want it to do much else - this is on a laptop: I don't want it to be accessible from the internet, and I don't need all sorts of fancy authentication.

Unfortunately, I haven't worked with mail services and I don't know the terminology, so I don't really know what I need to search for. When searching for postfix or sendmail, all the guides seem to be for setting up a "real" mail server.

Has anyone done this, and if so, what do you recommend?

Thanks in advance  :Smile: 

----------

## bjlockie

It is easy to do what you want with Postfix.

You can specify different Transport based on the target domain.

http://www.postfix.org/

----------

## xaviermiller

Hello,

I followed that old TIP https://forums.gentoo.org/viewtopic.php?t=61606

And my Gentoo boxes are fine with local mail (only)  :Smile: 

----------

## Etal

I've played with Postfix, but I still can't seem to figure out how to make it do what I need.

I got it to do system mail it I re-emerge msmtp with "-mta" flag, but I can't figure out how to make it replace msmtp.

First off, I can't find a way for it to pick which SMTP server to relay it to. I looked at the "transports" documentation, as bjlockie suggested, but it seems to look at where I'm sending to, which is not important. What I need is for it to look at what I'm sending from.

I have 3 accounts which I use regularly for different purposes. Currenlty, I have my mail client set the "From:" and let msmtp figure it out. For example, a mail like this:

```
From: Me <me@gmail.com>

To: Bob <bob123@yahoo.com>
```

will get sent to smtp.gmail.com

And this:

```
From: Me <me@isp.net>

To: Bob <bob123@yahoo.com>
```

will get sent through mail.isp.net

And I also want it to be able to do something like this (for cron jobs):

```
To: me@localhost, me@isp.net
```

That way, if something important happens, I would get a message whether I have no internet or I am somewhere away.

The second (more minor) problem is that I found no way to configure the mail as a user. With msmtp, there's a .msmtprc which contains all the information and passwords needed to send through SMTP. With Postfix, all the configuration seems to be in global /etc/postfix, so if I let someone use the machine with their own account, I assume they'd be able to send mail through my accounts.

The simplest "solution" that I can think of is to have Postfix do the same thing it does with Procmail ("mailbox_command"): hand over mail to a user process. So, if the mail is not local, it would launch msmtp as a user process (which reads the local configuration) and hands the message over to it. Unfortunately, I can't find an option to do that.  :Sad: 

Any further suggestions appreciated.

----------

## bjlockie

 *AM088 wrote:*   

> 
> 
> The second (more minor) problem is that I found no way to configure the mail as a user. With msmtp, there's a .msmtprc which contains all the information and passwords needed to send through SMTP. With Postfix, all the configuration seems to be in global /etc/postfix, so if I let someone use the machine with their own account, I assume they'd be able to send mail through my accounts.

 

The files in /etc/postfix are not readable by every user.

*I* or anyone can forge your domain and users, that is what some SPAM does.

I don't understand the situation because what I am thinking applies to ALL mailers (including msmtp.,

----------

## M

Hi, for this you will need to use postfix transport maps, something like this:

/etc/postfix/transport

me@gmail.com smtp.gmail.com:

me@isp.net smtp.isp.net:

and in main.cf you will need this:

transport_maps = hash:/etc/postfix/transport

then you make db with postmap command:

postmap /etc/postfix/transport

If you only need relay for one account you can just set relayhost in main.cf

----------

