Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question
    
Have you checked the logs to see how postfix is routing the email –  topdog Aug 20 '10 at 13:08
    
I see "dovecot" in my logs now. Can I see tasksel installed dovecot. Do you think dovecot makes the difference ? –  Andrew Aug 20 '10 at 13:22
    
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
add comment

2 Answers

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!

share|improve this answer
    
I reinstalled Ubuntu and installed just bind9 (for MX) and postfix. Email receiving is not working. I tried "dpkg-reconfigure" but still not working. –  Andrew Aug 20 '10 at 17:20
    
What is dpkg-reconfigure doing exacly ? ... I think it just create main.cf. So I created it manually –  Andrew 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. –  user51838 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. –  user51838 Aug 20 '10 at 19:35
    
I installed bind9 and I host my own DNS. I's simple to setup a MX record –  Andrew Aug 20 '10 at 20:07
show 1 more comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.