Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Ubuntu 9.04) - Page 4

12 Test Postfix

To see if Postfix is ready for SMTP-AUTH and TLS, run

telnet localhost 25

After you have established the connection to your Postfix mail server type

ehlo localhost

If you see the lines

250-STARTTLS

and

250-AUTH LOGIN PLAIN

everything is fine:

root@server1:/usr/local/sbin# telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 server1.example.com ESMTP Postfix (Ubuntu)
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
root@server1:/usr/local/sbin#

Type

quit

to return to the system shell.

 

13 Populate The Database And Test

To populate the database you can use the MySQL shell:

mysql -u root -p
USE mail;

At least you have to create entries in the tables domains and users:

INSERT INTO `domains` (`domain`) VALUES ('example.com');
INSERT INTO `users` (`email`, `password`, `quota`) VALUES ('sales@example.com', ENCRYPT('secret'), 10485760);

(Please take care that you use the ENCRYPT syntax in the second INSERT statement in order to encrypt the password!)

If you want to make entries in the other two tables, that would look like this:

INSERT INTO `forwardings` (`source`, `destination`) VALUES ('info@example.com', 'sales@example.com');
INSERT INTO `transport` (`domain`, `transport`) VALUES ('example.com', 'smtp:mail.example.com');

To leave the MySQL shell, type

quit;

For most people it is easier if they have a graphical front-end to MySQL; therefore you can also use phpMyAdmin (in this example under http://192.168.0.100/phpmyadmin/ or http://server1.example.com/phpmyadmin/) to administrate the mail database. Again, when you create a user, go sure that you use the ENCRYPT function to encrypt the password:

I do not think I have to explain the domains and users table further.

The forwardings table can have entries like the following:

source destination  
info@example.com sales@example.com Redirects emails for info@example.com to sales@example.com
@example.com thomas@example.com Creates a Catch-All account for thomas@example.com. All emails to example.com will arrive at thomas@example.com, except those that exist in the users table (i.e., if sales@example.com exists in the users table, mails to sales@example.com will still arrive at sales@example.com).
@example.com @anotherdomain.tld This redirects all emails to example.com to the same user at anotherdomain.tld. E.g., emails to thomas@example.com will be forwarded to thomas@anotherdomain.tld.
info@example.com sales@example.com, billing@anotherdomain.tld Forward emails for info@example.com to two or more email addresses. All listed email addresses under destination receive a copy of the email.

The transport table can have entries like these:

domain transport  
example.com : Delivers emails for example.com locally. This is as if this record would not exist in this table at all.
example.com smtp:mail.anotherdomain.tld Delivers all emails for example.com via smtp to the server mail.anotherdomain.com.
example.com smtp:mail.anotherdomain.tld:2025 Delivers all emails for example.com via smtp to the server mail.anotherdomain.com, but on port 2025, not 25 which is the default port for smtp.
example.com

smtp:[1.2.3.4]
smtp:[1.2.3.4]:2025
smtp:[mail.anotherdomain.tld]

The square brackets prevent Postfix from doing lookups of the MX DNS record for the address in square brackets. Makes sense for IP addresses.
.example.com smtp:mail.anotherdomain.tld Mail for any subdomain of example.com is delivered to mail.anotherdomain.tld.
* smtp:mail.anotherdomain.tld All emails are delivered to mail.anotherdomain.tld.
joe@example.com smtp:mail.anotherdomain.tld Emails for joe@example.com are delivered to mail.anotherdomain.tld.

See

man transport

for more details.

Please keep in mind that the order of entries in the transport table is important! The entries will be followed from the top to the bottom.

Important: Postfix uses a caching mechanism for the transports, therefore it might take a while until you changes in the transport table take effect. If you want them to take effect immediately, run

postfix reload

after you have made your changes in the transport table.

 

14 Send A Welcome Email For Creating Maildir

When you create a new email account and try to fetch emails from it (with POP3/IMAP) you will probably get error messages saying that the Maildir doesn't exist. The Maildir is created automatically when the first email arrives for the new account. Therefore it's a good idea to send a welcome email to a new account.

First, we install the mailx package:

aptitude install mailx

To send a welcome email to sales@example.com, we do this:

mailx sales@example.com

You will be prompted for the subject. Type in the subject (e.g. Welcome), then press ENTER, and in the next line type your message. When the message is finished, press ENTER again so that you are in a new line, then press CTRL+D; if you don't want to cc the mail, press ENTER again:

root@server1:/usr/local/sbin# mailx sales@example.com
Subject: Welcome
<-- ENTER
Welcome! Have fun with your new mail account. <-- ENTER
<-- CTRL+D
Cc: <-- ENTER
root@server1:/usr/local/sbin#

Share this page:

32 Comment(s)

Add comment

Comments

From: Antonio J. Delgado at: 2009-07-10 18:39:34

One thinkg I do before this is to hold the postfix package. Thereby I use the command:

echo "postfix hold" | dpkg --set-selections

 And apt won't update postfix in the future and the quotas still working.

Nice tutorial.

From: Pascal at: 2009-09-24 03:55:21

ERROR: Connection dropped by IMAP server

This is error that i got, and when i check log file :

 Sep 24 03:26:12 ser1 imapd: Connection, ip=[::1]
Sep 24 03:26:12 ser1 imapd: LOGIN FAILED, user=sale@example.dom, ip=[::1]
Sep 24 03:26:17 ser1 imapd: LOGOUT, ip=[::1], rcvd=53, sent=332
Sep 24 03:26:34 ser1 imapd: Connection, ip=[::1]
Sep 24 03:26:34 ser1 imapd: LOGIN FAILED, user=sale@example.com, ip=[::1]
Sep 24 03:26:39 ser1 imapd: LOGOUT, ip=[::1], rcvd=53, sent=332
Sep 24 03:26:53 ser1 postfix/postfix-script[4679]: refreshing the Postfix mail system
Sep 24 03:26:53 ser1 postfix/master[4562]: reload configuration /etc/postfix
Sep 24 03:29:42 ser1 imapd: Connection, ip=[::1]
Sep 24 03:29:42 ser1 imapd: chdir example.com/sales/: No such file or directory
Sep 24 03:29:45 ser1 imapd: Connection, ip=[::1]
Sep 24 03:29:45 ser1 imapd: chdir example.com/sales/: No such file or directory
Sep 24 03:29:49 ser1 imapd: Connection, ip=[::1]
Sep 24 03:29:49 ser1 imapd: chdir example.com/sales/: No such file or directory
Sep 24 03:30:45 ser1 postfix/smtpd[4662]: timeout after END-OF-MESSAGE from localhost.localdomain[127.0.0.1]
Sep 24 03:30:45 ser1 postfix/smtpd[4662]: disconnect from localhost.localdomain[127.0.0.1]
Sep 24 03:51:46 ser1 imapd: Connection, ip=[::1]
Sep 24 03:53:07 ser1 imapd: Connection, ip=[::1]

------

Any idea for my problem ..

thanks anyway

From: xdanx at: 2010-01-01 22:22:51

Hey mate, you need to send a mail first.

 you get Sep 24 03:29:45 ser1 imapd: chdir example.com/sales/: No such file or directory

because you didn't send a mail first . 

Run

mailx sales@example.com 

 Cheers, 

Dan

From: Anonymous at: 2010-11-11 02:37:36

ERROR: Connection dropped by IMAP server

I want it very much, because i'am too.

From: Larry at: 2009-11-26 01:27:59

I have been using this setup for my mail server and love it.   I have a problem that I have not been able to resolve and I was wondering if someone could help me out.   My server needs to have multiple IP addresses bound to one interface.   My problem is that postfix always wants to send mail using the highest IP address.  This behaviour will not work for my setup.  I have tried having Postfix bind to a specific address, but it breaks the ClamAV/Amasvisd.   Any suggestions on how I can work with this. 

From: Silvio Relli at: 2009-06-13 19:44:40

Hello

On page 2, when configuring postfix, giving this command:

postconf -e 'mydestination = server1.example.com, localhost, localhost.localdomain'

Il will not work, because server1.example.com is both on mydestination and in the domain table (on the db).

Postfix will say in the log: postfix/trivial-rewrite[1896]: warning: do not list domain server1.example.com in BOTH mydestination and virtual_mailbox_domains

Simply don't put server1.example.com inside mydestination

 Other users had the same problem: http://www.howtoforge.com/forums/showpost.php?p=42337&postcount=12

 

Ciao,

Sivlio

From: Dzy at: 2009-08-02 20:08:31

very good tutorial, thanks. 

 but having some trouble with smtp server, sending mail to world from webmail, where smtp is called as localhost is just fine, the problem begins in outlook, where i have to call smt as mail.address.tld.

error i got: 

Aug  2 22:57:56 ubuntu postfix/smtpd[8539]: NOQUEUE: reject: RCPT from unknown[x.x.x.x]: 554 5.7.1 <world@some-address.tld>: Relay access denied; from=<local@other-address.tld> to=<world@some-address.tld> proto=ESMTP helo=<[x.x.x.x]>. 

 any questions? or quick solution?

From: Anonymous at: 2009-09-18 00:42:01

So do we, anyfixes?

From: Jay at: 2009-09-18 00:56:34

If you get the RELAY ACCESS DENIED error in webmail or SquirrelMail open do this...  /usr/sbin/squirrelmail-configure   <-- then choose 2, for server settings, then change sending mail from SMTP to sendmail :)

From: Anonymous at: 2010-06-07 06:25:03

@Jay - That worked for me. Thanks!

 

If you get the RELAY ACCESS DENIED error in webmail or SquirrelMail open do this...  /usr/sbin/squirrelmail-configure   <-- then choose 2, for server settings, then change sending mail from SMTP to

 

 

From: Pablo R. Ferretti at: 2009-08-28 20:35:03

root@t300:/etc/postfix/sasl# tail /var/log/mail.log
Aug 28 17:16:35 t300 postfix/smtpd[3526]: connect from adm.xxx.com.br[189.xxx.xxx.5]
Aug 28 17:16:35 t300 postfix/smtpd[3526]: warning: SASL authentication failure: cannot connect to saslauthd server: No such file or directory
Aug 28 17:16:35 t300 postfix/smtpd[3526]: warning: adm.xxx.com.br[189.xxx.xxx.5]: SASL LOGIN authentication failed: generic failure
Aug 28 17:16:35 t300 postfix/smtpd[3526]: lost connection after AUTH from adm.xxx.com.br[189.xxx.xxx.5]
Aug 28 17:16:35 t300 postfix/smtpd[3526]: disconnect from adm.xxx.com.br[189.xxx.xxx.5]

Edit file: /etc/postfix/sasl/smtpd.conf

Insert line: saslauthd_path: /var/spool/postfix/var/run/saslauthd/mux

/etc/init.d/postfix restart

/etc/init.d/saslauthd restart

resolved problem!!

 

From: at: 2010-03-05 13:00:14

GREAT !!!!!!!!!!!!!!!!!!

This reply resolve my 8 month issue no body remove this error . I was not sleeping from last 8 months to having this issue this issue .

I asked from so many perosns 

Thanks Again !!! 

This forums must be together with followed tutorial http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu9.04

From: Antonio J Delgado at: 2009-06-22 11:13:41

In my case the 10th step didn't work until a change the provideer of the package dcc to this:
wget http://www.rhyolite.com/dcc/source/dcc.tar.Z && tar xzvf dcc.tar.Z

From: Joshua Flory at: 2009-07-15 01:08:56

Be careful in part 10 here.  The file name you download here doesn't reference the version, but the directory this gets extracted to has a different version than the one shown here.

 For example when I did this I got version 1.3.111 so I had to change just the step:

cd dcc-dccproc-1.3.104

to

cd dcc-dccproc-1.3.111

The rest of those commands stayed the same.

From: simple69 at: 2009-06-14 15:52:23

Awesome, thanks for this great guide falko.  Worked perfect the first time.:)

From: UNi at: 2009-10-16 19:41:18

This resolved the IMAP issue:

mkdir /home/vmail/example.com
chown -R vmail.vmail /home/vmail/example.com/yourname
maildirmake /home/vmail/example.com/yourname

 

-UNi

From: Khosro at: 2010-05-27 11:44:39

Hi UNi,

Thanks for your instructions.I have got this error " ERROR: Connection dropped by IMAP server." ,but your instructions solved my problem.

I only changed your instruction like this :

If your email address is "sales@example.com", so do the following instructions :

root@d3:~# mkdir /home/vmail/example.com/
root@d3:~# chown -R vmail.vmail /home/vmail/example.com/sales
root@d3:~# maildirmake /home/vmail/example.com/sales
root@d3:~# chown -R vmail.vmail /home/vmail/example.com/sales
 

Khosro.

From: Anonymous at: 2009-10-16 16:08:17

I have a problem ERROR: Connection dropped by IMAP server.

From: Louis_16 at: 2009-06-24 07:47:28

Thank's a lot for all this thankable job !

It was much more than helpful. It works perfectly and it solves all my needs.

Thnak's again.

From: Angelo A. at: 2009-06-29 03:55:56

I followed this tutorial and it actually works, there was a problem with the change_sql plugin because they have thier plugin site down.

I got a copy of this instead  squirrelmail-change-sqlpass-plugin-3.3.tbz

I am hoping this is the equivalent at the very least, anywys when I try to login I get this error:

ERROR: Connection dropped by IMAP server.

Normally I would check all the logs for errors but I am just starting out with Ubuntu and POSTFIX and am not sure what to look for or where all the logs are.

Any assistance would be greatly appreciated.

This is on an Ubuntu 9.04 server box, no head on it.

 

From: Glenn at: 2009-06-29 13:37:26

I am getting the exact same problem - dropped by imap server.... please help.

From: Rui Rocha at: 2009-08-23 14:50:05

The problem that IMAP dropeed by peer is because your mailbox didn't get any e-mail yet, and therefore the folder is not created.

 Try to send an e-mail to the account that you created and then check it again. I know that you follow the mailx on the tutorial, but imagine that your SMTP has not relay, then the e-mail that you sent, never got the mailbox!! Try to send an e-mail by hotmail, or something like that.

Thank, probably, you will get a BLANK PAGE. If it is so, pls unable the plugins. They are in conflict. I don't know yet the solution, but if it occurs is because of that.

VERY NICE AND GREAT TUTORIAL!!

Thanks

Rui

From: Fhox at: 2009-06-29 07:35:26

On 06/29/2009

SECURITY: SquirrelMail Webserver Compromised

Other option for download plugin's

 ftp://ftp.freebsd.org/pub/FreeBSD/ports/distfiles/squirrelmail/

 Slds
Fhox

From: Exp at: 2009-07-13 08:41:47

Hey excellent work!!! it worked at first too!!!

 I'd like to know how to install vacation with the configuration from this HOWTO.

 Thank you very much.

From: at: 2009-07-17 02:57:12

It's an awsome tuto... Thanks Falko.

what should I do next ? 

From: simple69 at: 2009-11-11 21:19:07

Make sure you follow the instructions for the mailx.  You have to send a test email to the email address first so that the system creates the maildir and such

From: rakeshakurathi at: 2010-01-14 16:47:41

using... i mean the installation process is specific for  one version...

 and follow the instructions line by line...

 i have taken 3 days to actually execute my mail server....

 if u any errors. don try to check where u have gone wrong ,just unistall the postfix first and redo it ----

 thanks falko....for ur tutorial .. can u help me to configure this mail server to outlook and thunderbird..

 

 

 

 

 

From: blatch at: 2011-12-15 11:58:28

i am using multilogin plugins and i have 3 domains. i select one of them from the homepage of squirrelmail. my problem is that 2 domains works but the other not working. i am using change_sqlpass plugins. And the error is Could not make database connection. how can it be worked?

From: Kaikun at: 2009-11-01 12:06:19

I have the same problem... either telnet or squirrelmail I cannot connect...

 

Nov  1 21:01:30 server02 pop3d: Connection, ip=[::ffff:114.149.77.124]
Nov  1 21:01:59 server02 pop3d: LOGIN, user=sales@my_domain.net, ip=[::ffff:114.149.77.124], port=[61349]
Nov  1 21:01:59 server02 pop3d: scancur opendir("cur"): No such file or directory
 

 

- Help!!!

From: D-Bo at: 2009-09-25 14:42:05

Will Spamassassin still poll local.cf for configuration? Will 'whitelist_from' work with this configuration?

From: Nakarti at: 2009-09-30 18:55:36

In trying to add sql_changepass to The Perfect Server with ISPConfig 3(since that howto gives a management console and worked the first try for me,) I had not installed PearDB before adding the sql changepass, and now that I have, get the error: "Could not find Pear DB library" when I try it.

Other questions on this error refer to whether peardb is installed, which it is, it has the components others list as missing, is there another service I have to restart than apache for PearDB to load properly?

(Courier has a terrible init script!)

From: DR at: 2009-09-06 21:08:31

Getting the exact same ERROR: Connection dropped by IMAP server.

 Here is the log:

Session is hitting the server but the server seems to be timing out or something... Sep  6 01:18:53 postfix postfix/smtp[17790]: 4C875306257: to=<sales@xxx.xxx.com>, relay=none, delay=2351, delays=2321/0.03/30/0, dsn=4.4.1, sta$
Sep  6 01:18:53 postfix postfix/smtp[17793]: 0B4BF306269: to=<myaccount@xxx.xxx.com>, relay=none, delay=362, delays=332/0.07/30/0, dsn=4.4.1, st$
Sep  6 01:18:53 postfix postfix/smtp[17792]: 6E90B306268: to=<myaccount@xxx.xxx.com>, relay=none, delay=546, delays=516/0.05/30/0, dsn=4.4.1, st$
Sep  6 01:18:53 postfix postfix/smtp[17791]: C8B6D306261: to=<myaccount@xxx.xxx.com>, relay=none, delay=1134, delays=1104/0.04/30/0, dsn=4.4.1, $
Sep  6 01:19:04 postfix imapd: Connection, ip=[::1]
Sep  6 01:19:04 postfix imapd: chdir xxx.xxx.com/myaccount/: No such file or directory
Sep  6 01:28:23 postfix postfix/qmgr[16842]: 6E90B306268: from=<myaccount@gmail.com>, size=2420, nrcpt=1 (queue active)
Sep  6 01:28:23 postfix postfix/qmgr[16842]: 0B4BF306269: from=<myaccount@mydomain.com>, size=1438, nrcpt=1 (queue active)
Sep  6 01:28:53 postfix postfix/smtp[17889]: connect to postfix.xxx.xxx.com[##.##.###.###]:25: Connection timed out
Sep  6 01:28:53 postfix postfix/smtp[17888]: connect to postfix.xxx.xxx.com[##.##.###.###]:25: Connection timed out
Sep  6 01:28:53 postfix postfix/smtp[17889]: 0B4BF306269: to=<myaccount@xxx.xxx.com>, relay=none, delay=963, delays=933/0.03/30/0, dsn=4.4.1, st$
Sep  6 01:28:53 postfix postfix/smtp[17888]: 6E90B306268: to=<myaccount@xxx.xxx.com>, relay=none, delay=1146, delays=1116/0.37/30/0, dsn=4.4.1, $

I suspect this could be a problem: Sep  6 01:19:04 postfix imapd: chdir xxx.xxx.com/myaccount/: No such file or directory

This tutorial is great...I feel like I'm almost there. I can get mail in through the firewall. I can get it to the server, i just cannot seem to get the connection to not timeout. Gah!

Any help would be greatly, greatly, appreciated.