# Postfix w/ Mysql w/ Sasl w/ Courier-IMAP Errors

## SnEptUne

Hi,

I have been trying to set up a mail server on my gentoo machine for 7 weeks, but I still couldn't get it working.  So I figure I should just post the problem on the forum.  I followed the virtual mail guide on http://www.gentoo.org/doc/en/virt-mail-howto.xml and http://www.gfxcafe.com/Mail%20Howto.htm, and http://www.geocities.com/scottlhenderson/spamfilter.html.  Unfortunately, the virt-mail-howto is so outdated that I couldn't follow the steps, such as where is /etc/sasl/smtpd.conf?  I only have a /etc/sasl2/smtpd.conf.  So I followed the other two guides instead, except I haven't implement spam filtering and virus scanning.  I would like to get the basic working first.  I will first list what my mail server could do right now:

1)  I could sent email to local user via local user with Mutt

2)  I could receive email of local users via IMAP with thunderbird on my local network.

3)  I could use TLS/SSL with IMAP.

4)  I could run and use mysql.

5)  I could run and configure my sql database with phpmyadmin on my local network.

To make things simplier, I will just list my major concern/problem since this is my first priority:

1)  I couldn't sent email at all via SMTP or mutt after I set up sasl and mysql.

Due to clipboard problem, I will post my /etc/postfix/main.cf, /etc/postfix/master.cf, /etc/sasl2/smtpd.conf, and /etc/conf.d/saslauthd on the followering post.

----------

## adaptr

Quick interjection here:

Make sure that Postfix is not configured to send all mail thru SASL!

If you do, hardly anybody will accept the connection, since it is not in widespread use on MTA's.

SMTP AUTH is only used to enable you to use a real MUA from a remote location - MTA's never use SASL between each other.

EDITed again: pfff I think I may have gotten a few things mixed up there

Let me try again:

- when you want to send mail via your MTA from a remote location, you use SASL (SMTP AUTH) since it's the only way to do so without opening up the MTA to spamasses (a so-called open relay).

- when it tries to send mail you also have to make sure it only uses normal SMTP so that every other MTA i the world will actually understand what it wants.

These are set in the recipient_restrictions and sender_restrictions options.

Make sure the normal SMTP options come first, since these rules are evaluated on a first-match basis.

----------

## SnEptUne

(/etc/postfix/main.cf)

```

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/lib/postfix

mail_owner = postfix

myhostname = mail.local.net

myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, localhost.$mydomain, $mydomain, $transport_maps

local_transport = local

local_recipient_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname

unknown_local_recipient_reject_code = 450

mynetworks = 192.168.1.0/24, 127.0.0.0/8

relayhost = $mydomain

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

alias_database = hash:/etc/postfix/aliases

home_mailbox = Maildir/

smtpd_banner = $myhostname ESMTP $mail_name

local_destination_concurrency_limit = 2

default_destination_concurrency_limit = 10

debug_peer_level = 5

debug_peer_list = $myhostname

debugger_command =

         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

         xxgdb $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = postdrop

manpage_directory = /usr/share/man

sample_directory = /etc/postfix/sample

readme_directory = /usr/share/doc/postfix-2.0.11

biff = no

smtpd_sasl_auth_enable = yes

smtpd_sasl2_auth_enable = yes

smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes

smtpd_sasl_local_domain = $mydomain

smtpd_recipient_restrictions =

   permit_sasl_authenticated,

   permit_mynetworks,

   reject_unauth_destination

smtpd_use_tls = yes

#smtpd_tls_auth_only = yes

smtpd_tls_key_file = /etc/postfix/newreq.pem

smtpd_tls_cert_file = /etc/postfix/newcert.pem

smtpd_tls_CAfile = /etc/postfix/cacert.pem

smtpd_tls_loglevel = 3

smtpd_tls_received_header = yes

smtpd_tls_session_cache_timeout = 3600s

tls_random_source = dev:/dev/urandom

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

virtual_transport = virtual

transport_maps = mysql:/etc/postfix/mysql-transport.cf

virtual_minimum_uid = 1000

virtual_gid_maps = static:1003

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

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

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

virtual_uid_maps = static:1003

virtual_mailbox_base = /home/vmail

#virtual_mailbox_limit =

smtp_sasl_password_maps = $alias_maps $virtual_mailbox_maps unix:passwd.byname

```

here's my /etc/postfix/master.cf

```

smtp      inet  n       -       y       -       -       smtpd -v

#smtps    inet  n       -       n       -       -       smtpd

#  -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes

#submission     inet    n       -       n       -       -       smtpd

#  -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes

#628      inet  n       -       n       -       -       qmqpd

pickup    fifo  n       -       y       60      1       pickup

cleanup   unix  n       -       y       -       0       cleanup

qmgr      fifo  n       -       y       300     1       qmgr

#qmgr     fifo  n       -       n       300     1       nqmgr

#tlsmgr   fifo  -       -       n       300     1       tlsmgr

rewrite   unix  -       -       y       -       -       trivial-rewrite

bounce    unix  -       -       y       -       0       bounce

defer     unix  -       -       y       -       0       bounce

flush     unix  n       -       y       1000?   0       flush

proxymap  unix  -       -       n       -       -       proxymap

smtp      unix  -       -       y       -       -       smtp -v

relay     unix  -       -       y       -       -       smtp

#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5

showq     unix  n       -       y       -       -       showq

error     unix  -       -       y       -       -       error

local     unix  -       n       n       -       -       local

virtual   unix  -       n       n       -       -       virtual

lmtp      unix  -       -       y       -       -       lmtp

maildrop  unix  -       n       n       -       -       pipe

  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}

old-cyrus unix  -       n       n       -       -       pipe

  flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}

cyrus     unix  -       n       n       -       -       pipe

  user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}

uucp      unix  -       n       n       -       -       pipe

  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)

ifmail    unix  -       n       n       -       -       pipe

  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)

bsmtp     unix  -       n       n       -       -       pipe

  flags=Fq. user=foo argv=/usr/sbin/bsmtp -f $sender $nexthop $recipient

```

Here's my /etc/sasl2/smtpd.conf

```

sasl_pwcheck_method: auxprop 

sasl_auxprop_plugin: mysql login plain crammd6 digestmd5 

mysql_user: mailsql 

mysql_passwd: $password 

mysql_hostnames: localhost 

mysql_database: mailsql

mysql_statement: SELECT clear FROM users WHERE email = '%u@%r' 

mysql_verbose: yes

```

Here's my /etc/conf.d/saslauthd

```

SASLAUTHD_OPTS=""

SASLAUTHD_OPTS="${SASLAUTH_MECH} -a pam"

```

----------

## SnEptUne

 *Quote:*   

> 
> 
> - when you want to send mail via your MTA from a remote location, you use SASL (SMTP AUTH) since it's the only way to do so without opening up the MTA to spamasses (a so-called open relay). 
> 
> - when it tries to send mail you also have to make sure it only uses normal SMTP so that every other MTA i the world will actually understand what it wants.
> ...

 

I think I am only using sasl for smtp.  I still need sasl for localnetwork, right?  Even though my localnetwork is trusted?  The problem is that I have no idea how I could get smtp to authicate against mysql without sasl.

----------

## adaptr

 *Quote:*   

> I think I am only using sasl for smtp.

 

And I think you have

```
smtpd_use_tls = yes
```

in your main.cf  :Wink: 

You asked for help with sending mail from your MTA to anywhere else.

If you want Postfix to be able to send mail anywhere not in your domain or localnet then remove reject_unauth_destination.

Read this: http://www.postfix.org/SASL_README.html#server_sasl

You might also want to reverse the first two options, since it seems quite silly to me to have to authenticate to your own mail server on your own network.

Unless you intend to start spamming yourself heavily.

HTH.

----------

## SnEptUne

We will only allow people from the local network to send email, but don't we need TLS?  Also, which two options are you referring to?

I have visited you link, but it doesn't mention how to authenticate against mysql.  Is it because auxprop_plugin:  mysql never existed?  Am I using the wrong plugin?  In fact, do I need to authenticate my users from my local network at all?  If not, do I just change smtpd_sasl_auth_enable = no?  And should I unmerge sasl?

Edit:  I don't need sasl for my localnetwork, but in the future, I may need to be able to use smtp oversea (not local network), but that's for later.  However, I think I will just setup a webmail instead.  It would be more secure and convinent, I guess.

Edit:  Anyway, I have removed anything related to TLS and sasl in main.cf and I could send email alright.  People from Internet can't access smtp on this server with my current setup (without sasl and TLS), right?

At any rate, here's the second problem:  after I send my email via smtp with thunderbird, I couldn't receive them via IMAP.  I could save draft, send email, but the email that I send (to test@local.net from test@local.net) doesn't return to me.  Here's my /var/log/messages:

```

08:27:23 mail postfix/smtpd[6104]: extract_addr: result: test@local.net

08:27:23 mail postfix/smtpd[6104]: fsspace: .: block size 4096, blocks free 269203

08:27:23 mail postfix/smtpd[6104]: smtpd_check_size: blocks 4096 avail 269203 min_free 0 size 0

08:27:23 mail postfix/smtpd[6104]: connect to subsystem public/cleanup

08:27:23 mail postfix/smtpd[6104]: public/cleanup socket: wanted attribute: queue_id

08:27:23 mail postfix/smtpd[6104]: input attribute name: queue_id

08:27:23 mail postfix/smtpd[6104]: input attribute value: CCD0B7D423

08:27:23 mail postfix/smtpd[6104]: public/cleanup socket: wanted attribute: (list terminator)

08:27:23 mail postfix/smtpd[6104]: input attribute name: (end)

08:27:23 mail postfix/smtpd[6104]: send attr flags = 2

08:27:23 mail postfix/smtpd[6104]: CCD0B7D423: client=workstation04.local.net[192.168.1.104]

08:27:23 mail postfix/smtpd[6104]: > workstation04.local.net[192.168.1.104]: 250 Ok

08:27:23 mail postfix/smtpd[6104]: watchdog_pat: 0x10066020

08:27:23 mail postfix/smtpd[6104]: < workstation04.local.net[192.168.1.104]: RCPT TO:<test@local.net>

08:27:23 mail postfix/smtpd[6104]: extract_addr: input: <test@local.net>

08:27:23 mail postfix/smtpd[6104]: extract_addr: result: test@local.net

08:27:23 mail postfix/smtpd[6104]: generic_checks: START

08:27:23 mail postfix/smtpd[6104]: generic_checks: name=permit_mynetworks

08:27:23 mail postfix/smtpd[6104]: permit_mynetworks: workstation04.local.net 192.168.1.104

08:27:23 mail postfix/smtpd[6104]: match_hostname: workstation04.local.net ~? 192.168.1.0/24

08:27:23 mail postfix/smtpd[6104]: match_hostaddr: 192.168.1.104 ~? 192.168.1.0/24

08:27:23 mail postfix/smtpd[6104]: generic_checks: name=permit_mynetworks status=1

08:27:23 mail postfix/smtpd[6104]: ctable_locate: leave existing entry key test@local.net

08:27:23 mail postfix/smtpd[6104]: maps_find: recipient_canonical_maps: test@local.net: not found

08:27:23 mail postfix/smtpd[6104]: maps_find: recipient_canonical_maps: test: not found

08:27:23 mail postfix/smtpd[6104]: maps_find: recipient_canonical_maps: @local.net: not found

08:27:23 mail postfix/smtpd[6104]: mail_addr_find: test@local.net -> (not found)

08:27:23 mail postfix/smtpd[6104]: maps_find: canonical_maps: test@local.net: not found

08:27:23 mail postfix/smtpd[6104]: maps_find: canonical_maps: test: not found

08:27:23 mail postfix/smtpd[6104]: maps_find: canonical_maps: @local.net: not found

08:27:23 mail postfix/smtpd[6104]: mail_addr_find: test@local.net -> (not found)

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup using sql query: select destination from virtual where e

mail = 'test@local.net' 

08:27:23 mail postfix/smtpd[6104]: dict_mysql: successful query from host 127.0.0.1

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup: retrieved 0 rows

08:27:23 mail postfix/smtpd[6104]: maps_find: virtual_alias_maps: test@local.net: not found

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup using sql query: select destination from virtual where e

mail = 'test' 

08:27:23 mail postfix/smtpd[6104]: dict_mysql: successful query from host 127.0.0.1

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup: retrieved 0 rows

08:27:23 mail postfix/smtpd[6104]: maps_find: virtual_alias_maps: test: not found

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup using sql query: select destination from virtual where e

mail = '@local.net' 

08:27:23 mail postfix/smtpd[6104]: dict_mysql: successful query from host 127.0.0.1

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup: retrieved 0 rows

08:27:23 mail postfix/smtpd[6104]: maps_find: virtual_alias_maps: @local.net: not found

08:27:23 mail postfix/smtpd[6104]: mail_addr_find: test@local.net -> (not found)

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup using sql query: select destination from alias where ali

as = 'test@local.net' 

08:27:23 mail postfix/smtpd[6104]: dict_mysql: successful query from host 127.0.0.1

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup: retrieved 0 rows

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup using sql query: select maildir from users where email =

 'test@local.net' and postfix = 'y'

08:27:23 mail postfix/smtpd[6104]: dict_mysql: successful query from host 127.0.0.1

08:27:23 mail postfix/smtpd[6104]: dict_mysql_lookup: retrieved 1 rows

08:27:23 mail postfix/smtpd[6104]: maps_find: local_recipient_maps: mysql:/etc/postfix/mysql-virtual-maps.cf:

 test@local.net = /home/test/.maildir/

08:27:23 mail postfix/smtpd[6104]: mail_addr_find: test@local.net -> /home/test/.maildir/

08:27:23 mail postfix/smtpd[6104]: > workstation04.local.net[192.168.1.104]: 250 Ok

08:27:23 mail postfix/smtpd[6104]: watchdog_pat: 0x10066020

08:27:23 mail postfix/smtpd[6104]: < workstation04.local.net[192.168.1.104]: DATA

08:27:23 mail postfix/smtpd[6104]: > workstation04.local.net[192.168.1.104]: 354 End data with <CR><LF>.<CR><

LF>

08:27:23 mail postfix/cleanup[6105]: CCD0B7D423: message-id=<opsd4znpnp67blsj@workstation04>

08:27:23 mail postfix/smtpd[6104]: public/cleanup socket: wanted attribute: status

08:27:23 mail postfix/smtpd[6104]: input attribute name: status

08:27:23 mail postfix/smtpd[6104]: input attribute value: 0

08:27:23 mail postfix/smtpd[6104]: public/cleanup socket: wanted attribute: reason

08:27:23 mail postfix/smtpd[6104]: input attribute name: reason

08:27:23 mail postfix/smtpd[6104]: input attribute value: (end)

08:27:23 mail postfix/smtpd[6104]: public/cleanup socket: wanted attribute: (list terminator)

08:27:23 mail postfix/smtpd[6104]: input attribute name: (end)

08:27:23 mail postfix/smtpd[6104]: > workstation04.local.net[192.168.1.104]: 250 Ok: queued as CCD0B7D423

08:27:23 mail postfix/smtpd[6104]: watchdog_pat: 0x10066020

08:27:23 mail postfix/qmgr[6101]: CCD0B7D423: from=<test@local.net>, size=674, nrcpt=1 (queue active)

08:27:24 mail postfix/virtual[6115]: CCD0B7D423: to=<test@local.net>, relay=virtual, delay=1, status=sent (m

aildir)

08:27:24 mail postfix/smtpd[6104]: < workstation04.local.net[192.168.1.104]: QUIT

08:27:24 mail postfix/smtpd[6104]: > workstation04.local.net[192.168.1.104]: 221 Bye

08:27:24 mail postfix/smtpd[6104]: disconnect from workstation04.local.net[192.168.1.104]

08:27:24 mail postfix/smtpd[6104]: master_notify: status 1

08:27:24 mail postfix/smtpd[6104]: connection closed

08:27:24 mail postfix/smtpd[6104]: watchdog_stop: 0x10066020

08:27:24 mail postfix/smtpd[6104]: watchdog_start: 0x10066020

08:28:26 mail sshd(pam_unix)[6123]: authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=localh

ost  user=test

08:28:28 mail sshd[6121]: error: PAM: Authentication failure for test from localhost

08:28:31 mail sshd[6121]: Accepted keyboard-interactive/pam for test from 127.0.0.1 port 32778 ssh2

08:28:31 mail sshd(pam_unix)[6125]: session opened for user test by (uid=0)

08:28:55 mail sshd(pam_unix)[6125]: session closed for user test

08:29:03 mail postfix/smtpd[6104]: rewrite stream disconnect

08:29:03 mail postfix/smtpd[6104]: watchdog_stop: 0x10066020

08:29:03 mail postfix/smtpd[6104]: watchdog_start: 0x10066020

08:29:04 mail postfix/smtpd[6104]: idle timeout -- exiting

08:29:06 mail xinetd[5981]: START: vnc-720x540x16 pid=6131 from=192.168.1.104

08:29:07 mail su(pam_unix)[6132]: session opened for user nobody by (uid=0)

08:29:07 mail su(pam_unix)[6132]: session closed for user nobody

08:30:07 mail (root-6219): starting (version 2.6.0), pid 6219 user 'root'

08:30:07 mail (root-6219): Resolved address "xml:readonly:/etc/gconf/gconf.xml.mandatory" to a read-only conf

ig source at position 0

08:30:07 mail (root-6219): Resolved address "xml:readwrite:/root/.gconf" to a writable config source at posit

ion 1

08:30:07 mail (root-6219): Resolved address "xml:readonly:/etc/gconf/gconf.xml.defaults" to a read-only confi

g source at position 2

08:30:30 mail imapd-ssl: Connection, ip=[192.168.1.200]

08:30:31 mail imapd-ssl: LOGIN, user=test@local.net, ip=[192.168.1.200], protocol=IMAP

08:30:35 mail imapd-ssl: Connection, ip=[192.168.1.200]

08:30:35 mail imapd-ssl: LOGIN, user=test@local.net, ip=[192.168.1.200], protocol=IMAP

08:30:38 mail imapd-ssl: Connection, ip=[192.168.1.200]

08:30:38 mail imapd-ssl: LOGIN, user=test@local.net, ip=[192.168.1.200], protocol=IMAP

08:33:30 mail sshd[6241]: Accepted keyboard-interactive/pam for root from 192.168.1.104 port 1103 ssh2

08:33:30 mail sshd(pam_unix)[6244]: session opened for user root by root(uid=0)

```

192.168.1.200 is my mail server and 192.168.1.0/24 is my local network.

----------

## SnEptUne

I guess I have edited my previous post too much.  Anyway, I can send email with MUTT and recieved them via IMAP.  But when I send email with SMTP, I couldn't recieve them.  Thus, I concluded that it is a SMTP related problem.  Interesting, I couldn't find the email that I sent (but couldn't receive) in my queue.  Does it mean it was sent successfully?  Then where is the email?

Edit:  I could send and receive email now.  I realized that I have treated test as a local user before.  Although it is true that test is indeed a local user, but I in the transport maps, the destination for domain local.net is to virtual:.  So, the emails are forwarded to the virtual mail directory instead while my home dir is mapped to the local home dir.  So of course I didn't recieve email that I just sent.  But it seems so inconvinent to create a virtual user.  You have to set up the proper uid, gid, home dir, maildir, password, and email.  Then you have to send an email in order for postfix to create the directory.  Is there are more ... user friendly interface then phpmyadmin?  I worry that if I died or disappeared, the person who will take up my position would be clueless since there are not too many linux user over here.

----------

## adaptr

If there are "not too many Linux users over there", and they are serious abuot their e-mail, perhaps you could persuade them to shell out for something like SuSE Mail Server, which costs about $500.

It has GUI interfaces for anyhing related to mail, and should be fairly easy to administer, even for someone from a Windows background.

I realise this is close to blasphemy on these forums (and you will, too, once you've been here a while  :Wink: ) but come on - you confuse a lot of issues in your posts, none of which, unfortunately, I have been able to decipher succesfully - or even to the point of replying intelligently.

E-mail is a complex subject; there are really no shortcuts, unless you're prepared to pay for them.

And no, you should never ever need authenticated SMTP on your local network, but that has nothing to do with using SMTP from the outside.

Postfix is perfectly capable of distinguishing between those (and all other) cases.

A big help in situations like these may be to draw diagrams of what, exactly, you want to achieve - break it up into smaller pieces, since most e-mail configurations are just a collection of simple routing decisions.

----------

## jewps

Dump all of that, use Xmail, Courier Imap and Smartpost.

You can find all of that at xmailserver.org and if you need help setting it up, PM me. Use the smartpost guide to start off first. Basically, Smartpost is a php mysql front-end to Xmail, you can give domain access out, MTA access and even subdomain. It makes managing sooo much easier. Next, you'll want to use courier-imap-ssl with mysql, that gives you control over logins via smartpost's php front end using mysql as the user lookups.

Xmail's filters are great too, you can use just about anything you want. Highly recommended, oh btw, by default gentoo installs xmail into a chroot enviroment.

----------

## adaptr

Xmail has finally gone production-ready ?

GOOD !

I'm going to try it.

----------

## SnEptUne

The problem is that I am not confident about the other MTA.  Postfix is good for its security and performance.  Since it exists for a long time, there are many documentation and testing done for postfix.  As for my setup, here's the diagram:

Domain: local.net

RECEIVING:

Local Domain Users (Windows Users) ---> Outlook Express ---> IMAP  ---> Virtual Transport (Database MySQL) ---> Users Database in MySQL (not local user) ---> MTA

SENDING:

Local Domain Users (Windows Users) ---> SMTP ---> MTA ---> INTERNET/Local

```

Virtual User    -->     SMTP      --> Filters (for Spams and Virus) 

                                       |

On Local Network                       |

                                       V

Virual User    <--      IMAP     <--  MTA -->  Firewall --->  INTERNET

                                       ^

                                       |

                                       |

                             Some webmail programs   <--  Apache2    <--- INTERNAT

                                                                      (Oversea Users)

```

I am not quite sure how does MTA send email to the Internet though.  There is something about MX hosts which I don't quite understand.

I will need spam scanning, virus-scanning, and webmail too.

As for Xmail, I have never heard of it.  My users would recieve thounsands or email per day (around 50 windows users), so I need a robust and secure email system since e-mail is critical for them since they use email for sale orders, purchasing, trading, designs, and others.[/code]

----------

## adaptr

 *Quote:*   

> I am not quite sure how does MTA send email to the Internet though.

 

With SMTP.

 *Quote:*   

> There is something about MX hosts which I don't quite understand. 

 

What is there to understand ?

I think you need to read up a little on SMTP and the e-mail chain of events in general, to get a better feel for how this all works.

An MTA actually fulfills at least 3 distinct roles, so this might be one source of your confusion.

It can send mail to the Internet - to another MTA, anywhere else is impossible.

It processes local mail, i.e. mail that never gets off your local domain.

And it is always listening for mail from the Internet - also from another MTA.

When your MTA wants to send mail to a remote domain the following happen - in sequence:

- MTA does a DNS query for the Mail eXchanger of the destination domain.

- MTA tries to open an SMTP connection to this MX

- MTA tries to send mail destined for that domain for as long as it has any

- MTA shuts down connection.

Anything that gets in the way of this happening means sending mail will fail.

Apart from the last bit, admittedly: you could pull the plug and the mail would still have been sent.

----------

## SnEptUne

Thanks for the information.  I guess I will continue to use postfix instead since I have it working already.  It should be able to send to the internet if that's the case.  All I need to do is the get filtering and administrative tools working.  Btw, do you have any suggestion on which tools (with good user interface) to use for managing postfix virtual users, their quota, the postfix's mail behaviours, and to create the virtual users' maildir?

----------

## adaptr

webmin is the best I can give you.

----------

## SnEptUne

webmin is only good for postfix configuration stored in main.cf though.  Since I have many tables stored in mySQL, it still quite useless.  It can see mailbox, but it can't see virtual mailbox, virtual users, their quota, their password etc etc.  phpmyadmin is good for creating users and such, but it may seems too complex for normal windows users.  Is there a tools that integrete mySQL and postfix configuration?  postfix admin does that, but it lacks functionalities.

I thought I could sent email to other domain, but it fails with the error messages "User unknown in local recipient table".

----------

## SnEptUne

Nevermind.  I could sent email to outside world (Mail servers on the Internet) now after I commented out this line:

```
relayhost = $mydomain
```

Is there anyway for me to create virtual user simpler instead of adding a record in the user table?  Addtionally, what is virtual_alias_map and virtual_mailbox_map?

----------

## adaptr

PHP has an excellent interface to mysql; you can probably write a script to add mail users in less than 20 lines of PHP.

You do have phpmyadmin installed, I assume ?

Life is hard without it  :Wink: 

----------

## SnEptUne

 *adaptr wrote:*   

> PHP has an excellent interface to mysql; you can probably write a script to add mail users in less than 20 lines of PHP.
> 
> You do have phpmyadmin installed, I assume ?
> 
> Life is hard without it 

 

Yes, I have it installed.  But how do I write a PHP Script that create virtual users maildir on the fly?  Is it even possible to tell postfix to send an email to newly created users or must I do so manually so that their home directory will be created?

----------

## adaptr

 *SnEptUne wrote:*   

> how do I write a PHP Script that create virtual users maildir on the fly?

 

Any way you want to - if the script creates new users you have all the information you need: their user name.

If the virtual mail system doesn't allow you to do this then you can simply make the directory from PHP directly - and still send a test mail  :Wink: 

 *SnEptUne wrote:*   

>   Is it even possible to tell postfix to send an email to newly created users

 

Anything is possible with PHP; since it also has a very advanced SMTP interface you don't need postfix for that.

 *SnEptUne wrote:*   

>  or must I do so manually so that their home directory will be created?

 

Like I said - your choice.

----------

## SnEptUne

I have no idea how to write a php script like that.  There are more problems though.  Postfix doesn't create any maildir for any newly created users.

----------

