-1

I just bought a dedicated server and I'm trying to install a webserver on it. The server is Ubuntu 10.04. I installed ftp, nginx, php, mysql, bind and now I have to install mail server.

For the mail server I'm using Postfix, because it's recomended on ubuntu.
I installed Postfix with apt-get install postfix but mail() function from php wasn't working. After a little debug I found the way to solve this : I created an empty file /etc/postfix/main.cf and it worked good.

I do have a mx record like this

mail                5M IN A     xxx.xxx.xxx.xxx
example.com.        5M IN MX    1 mail.example.com.

After that I wanted to forward all e-mails to my GMail address. So I googled for it and I found in the official docs Virtual Domain Host Forwarding

I added these lines in main.cf

virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual

I created map file and I placed this line in it

@example.com me@gmail.com

I run in terminal

postmap /etc/postfix/virtual
postfix reload

The result: I can send e-mail from php with mail() function, but when I send an email to anything@example.com that e-mail isn't forwarded to my Gmail.

How to solve this?

-Andrew


I also tried this but not working http://rackerhacker.com/2006/12/26/postfix-virtual-mailboxes-forwarding-externally/


It works now! But I don't know what the problem was. I just installed "Mail Server" from Tasksel and after that it worked fine. Can anyone tell me what Tasksel installed or that it changed ?

  • Have you checked the logs to see how postfix is routing the email – topdog Aug 20 '10 at 13:08
  • normal help type info for debugging postfix includes the output from a `postconf -n` and any pertinent log info – Greeblesnort Aug 20 '10 at 13:22
  • I see "dovecot" in my logs now. Can I see tasksel installed dovecot. Do you think dovecot makes the difference ? –  Aug 20 '10 at 13:22

2 Answers2

1

To investigate what tasksel has/will load use:

$ tasksel --task-packages mail-server                             ~
dovecot-imapd
procmail
dovecot-common
postfix
libpth20
libmysqlclient16
libgpgme11
mutt
libpq5
dovecot-pop3d
bsd-mailx
ssl-cert
mysql-common

Most of these are security neutral-- except dovecot. Dovecot is an excellent and very secure IMAP (server-side mail) service. But, it does not belong on a typical webserver, and has nothing to do with sending mail.

What solved your problem is just that taskel ran the following command for you:

sudo dpkg-reconfigure postfix

Since your mail works now, just uninstall dovecot's packages:

sudo aptitude purge dovecot-common dovecot-imapd dovecot-pop3d

Good luck!

  • I reinstalled Ubuntu and installed just bind9 (for MX) and postfix. Email receiving is not working. I tried "dpkg-reconfigure" but still not working. –  Aug 20 '10 at 17:20
  • What is dpkg-reconfigure doing exacly ? ... I think it just create main.cf. So I created it manually –  Aug 20 '10 at 17:30
  • dpkg-reconfigure run the config process for a package. For postfix, the main result is a proper main.cf file. But, /etc/mailname is modified as well. To mail to gmail, you need to relay the mail off a publicly addressable mail server. So a public MX record matching your system's mailname (usually defined in /etc/mailname) must exist. It sounds strange to me that you'd have a MX addressable system as a webserver, but you can do that. –  Aug 20 '10 at 19:35
  • Unless you are running the *public* DNS for your domain, bind9 will do nothing for you. Register your MX record with your DNS registrar like joker.com, or godaddy.com. –  Aug 20 '10 at 19:35
  • I installed bind9 and I host my own DNS. I's simple to setup a MX record –  Aug 20 '10 at 20:07
  • Ah, indeed. Then I expect the mailname postfix is advertising in the SMTP exchange does not exactly match the MX record. But, it is hard to know without looking at the log chatter. –  Aug 20 '10 at 21:03
0

When you said "I send mail to anything@example.com", do you mean via another external account?

It sounds to me like your local mail delivery (php scripts calling mail()) is forwarding correctly, but your global internet mail delivery for example.com is not flowing to this box.

For that you'll need to make sure you have a MX record on example.com's DNS config that points to your server.

Joel K
  • 5,765
  • 2
  • 29
  • 34