# Problems with postfix

## netcho

Hello to all!

I've been following this guide http://www.gentoo.org/doc/en/virt-mail-howto.xml but it seems that postfix isnt receving any mail at all. please help me with that problem, please.

----------

## VinzC

What do you mean «isn't receiving any mail»? Is it from the outside -- so have you tried to configure a private mail server with public access for distributing incoming mail to local recipients? Or do you want to have a private mail service for your local users?

----------

## netcho

well i think that as a start, may be 3 or 4 users are going to use it. so lets call it a private server. I missed to say that I've pointed in

```
 

/etc/mail/aliases

root        myemail@smth.com

```

where myemail@smth.com is my email in an other email server. And if i send the email to root it sends it to myemail@smth.com! How to send an email which will be stored ot my computer?

----------

## VinzC

There are still too many things to guess.

A mail server can act asa simple relay - it does only forward incoming messages to a mail server on the Internet, doesn't deliver message to local users

a local mail server with local mailboxes - it delivers mail messages to local users

a combination of both - it forwards mail messages addressed to unknown people to a mail server on the Internet and stores mail messages sent to local user accounts on a local storage space

a combination of the first three plus a remote access service like IMAP, POP3 - users may access their mailbox on the mail server remotely using a mail protocol like IMAP, POP3 aso.All these configurations have their prerequisites and pitfalls. E.g. if your mail server shall receive mail messages from the Internet, it may not use a dynamic IP address, though it's technically possible. You also must configure your mail server to forward mail messages using your ISP mail server if the forwarded destination is part of a non local domain.

Which of these are you trying to achieve? When you send a mail message, are you using ssmtp, mailx, nail, sendmail, whatever? Have you made sure these clients are configured properly? Does your mail server have access to the Internet?

I'm guessing what you're trying to do for now is just a simple mail relay. But in this case, all you would need to use is nail, mailx or ssmtp. BTW guessing is not what I do best...

----------

## cach0rr0

 *netcho wrote:*   

> well i think that as a start, may be 3 or 4 users are going to use it. so lets call it a private server. I missed to say that I've pointed in
> 
> ```
>  
> 
> ...

 

correct. This is expected behaviour, and the purpose of alias_maps 

I want all of my email redirected to 'meat', so I have:

```

meat@gentoob0x ~ $ sudo cat /etc/mail/aliases

# Basic system aliases -- these MUST be present.

MAILER-DAEMON:      postmaster

postmaster:         meat

# General redirections for pseudo accounts.

adm:                meat

bin:                meat

daemon:             meat

```

this means that the postfix delivery agent will send to meat@ instead of whateverotheruse@

 *Quote:*   

> How to send an email which will be stored ot my computer?

 

I think you're talking of another delivery  mechanism, such as IMAP or POP

IMAP will leave the messages stored on the server

POP does a pull from the server

up to you which route you want to go - difficult to say based upon the very very limited information we have thus far. 

From what I can tell, your mail is being delivered locally onto the mail server (as designed), and all you need is an IMAP/POP system so that your client can actually read the mail from the server. If so, and this is indeed a very small private server, Dovecot is probably the easiest to set up. 

I don't know if this will be helpful for you or not, but, I have my entire setup documented here:

https://whitehathouston.com/topics/index.php/WHHMail

(ignore the certificate errors!)

it is a very basic system with maybe a dozen or so local users - completely functional example

----------

## netcho

OK, Now I now exactly the problem. So I sent an email from gmail to root@okbg.vt.evo.bg (okbg.vt.evo.bg is my hostname which I have from my ISP) and Postfix stores the mail into /root/.maildir while courier-imap reads the mail in /home/vmail/okbg.vt.evo.bg/root/.maildir . I tried to link them but no sucsees!

----------

## VinzC

 *netcho wrote:*   

> So I sent an email from gmail to root@okbg.vt.evo.bg (okbg.vt.evo.bg is my hostname which I have from my ISP) and Postfix stores the mail into /root/.maildir while courier-imap reads the mail in /home/vmail/okbg.vt.evo.bg/root/.maildir .

 

Aha... So your mail server is publicly accessible from the Internet...

----------

## cach0rr0

 *netcho wrote:*   

> OK, Now I now exactly the problem. So I sent an email from gmail to root@okbg.vt.evo.bg (okbg.vt.evo.bg is my hostname which I have from my ISP) and Postfix stores the mail into /root/.maildir while courier-imap reads the mail in /home/vmail/okbg.vt.evo.bg/root/.maildir . I tried to link them but no sucsees!

 

ok, so this makes more sense now

your aliasing isnt working (also, get rid of that symlink - you don't need it)

I've not used mysql for aliases, but it looks very straightforward. Basically you define a config variable in main.cf that tells postfix to use mysql for its alias_maps. In your case it looks like this is the portion that is broken. 

Could you paste your main.cf into http://pastebin.ca and share the link with us? That would help immensely. 

I would also tail -f /var/log/mail.log  and send a mail, then copy that into pastebin.ca as well, send us both links.

----------

## cach0rr0

Ok, here we go. This is the section from that document that you need to pay attention to - and the section that is not working for you

```

(Ensure that there are no other alias_maps definitions)

alias_maps = mysql:/etc/postfix/mysql-aliases.cf

relocated_maps = mysql:/etc/postfix/mysql-relocated.cf

local_transport = local

local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname

virtual_transport = virtual

(The domains listed by the mydestination should not be listed in

 the virtual_mailbox_domains parameter)

virtual_mailbox_domains = virt-domain.com, $other-virtual-domain.com

virtual_minimum_uid = 1000

(Substitute $vmail-gid with the GID of the vmail group)

virtual_gid_maps = static:$vmail-gid

virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-maps.cf

virtual_alias_maps = mysql:/etc/postfix/mysql-virtual.cf

(Substitute $vmail-uid with the UID of the vmail user)

virtual_uid_maps = static:$vmail-uid

virtual_mailbox_base = /

```

As it says above as well, make sure that you do not have another alias_maps parameter defined, as it will take precedence. 

You have mentioned that you edited /etc/mail/aliases - that makes me think you have an alias_maps definition already, which is breaking your virtual alias maps

----------

## netcho

Well it the howto it sead to include mailman with 

```
alias_maps = hash:/path/to/mailman/data/aliases,

                             mysql:/path/to/mysql.cf

```

So I did it. But I cant edit it right now becouse I'm not at home. I'll try tomorrow but thanks for the advice

----------

## cach0rr0

well no, that looks fine actually 

couldn't really say heaps without seeing main.cf, but we're in the right area at least. It's the alias redirect that's choking!

----------

## VinzC

Do you really need mysql for aliases? I'd advise to first work with aliases in a flat file (actually /etc/aliases). Having a database for just 3-4 users adds useless complexity IMHO and is a little... overkill.

----------

## netcho

here is the link to my main.cf link and to the mail.log  link2 but when I send a mail to root@okbg.vt.evo.bg it receives it and I can read it trought squirellmail. Also I can't send mail from other emails on this server as koko@okbg.vt.evo.bg. Its says : unknown user koko

----------

