Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Ubuntu Linux 12.04.1 With LAMP stack.

The goal is to setup a web server that can send mail via the PHP mail() function, which uses localhost. The mail must then be relayed to an ISP domain smtp.isp-domain.co.za

Please note the domain names have been replaced in this question and probably don’t exist. The dedicated server IP is static.

The mail server has been setup according to the following guide; http://www.pixelinx.com/2010/10/creating-a-mail-server-on-ubuntu-using-postfix-courier-ssltls-spamassassin-clamav-and-amavis/

Problem 1: Email is being looped back to server;

Apr 18 08:35:20 Primary-domain postfix/qmgr[1033]: 2ED0138ADD2B: from=<root@mail.secondary-domain.co.za>, size=740, nrcpt=1 (queue active)
Apr 18 08:35:20 Primary-domain postfix/virtual[1397]: 22EBB38AFF28: to=<root@secondary-domain.co.za>, orig_to=<root>, relay=virtual, delay=25410139, delays=25410138/0.3/0/0.1, dsn=2.0.0, status=sent (delivered to maildir)
Apr 18 08:35:20 Primary-domain postfix/pickup[1032]: 37F9D38AC10F: uid=0 from=<root>
Apr 18 08:35:20 Primary-domain postfix/cleanup[4977]: 37F9D38AC10F: message-id=<20130418063520.37F9D38AC10F@Primary-domain.localdomain>
Apr 18 08:35:20 Primary-domain postfix/virtual[1404]: 3F2E238B3BBA: to=<root@secondary-domain.co.za>, orig_to=<root>, relay=virtual, delay=19563438, delays=19563438/0.26/0/0.1, dsn=2.0.0, status=sent (delivered to maildir)
Apr 18 08:35:20 Primary-domain postfix/qmgr[1033]: 22EBB38AFF28: removed
Apr 18 08:35:20 Primary-domain postfix/qmgr[1033]: 3FA7F38B61F7: from=<root@mail.secondary-domain.co.za>, size=1172, nrcpt=1 (queue active)
Apr 18 08:35:20 Primary-domain postfix/pickup[1032]: 7B29C38AF247: uid=0 from=<root>
Apr 18 08:35:20 Primary-domain postfix/cleanup[4977]: 7B29C38AF247: message-id=<20130418063520.7B29C38AF247@Primary-domain.localdomain>
Apr 18 08:35:20 Primary-domain postfix/qmgr[1033]: 3F2E238B3BBA: removed

Problem 2: Address resolver failure;

Apr 18 08:35:08 Primary-domain postfix/cleanup[4977]: 1E22B38B7E81: message-id=20130418063508.1E22B38B7E81@Primary-domain.localdomain
Apr 18 08:35:08 Primary-domain postfix/error[4972]: 6E71038B60B1: to=<root@secondary-domain.co.za>, orig_to=<root>, relay=none, delay=36082087, delays=36082087/0.23/0/0.1, dsn=4.3.0, status=deferred (address resolver failure)
Apr 18 08:35:08 Primary-domain postfix/qmgr[1033]: F1F1038B79D8: from=<root@mail.secondary-domain.co.za>, size=1203, nrcpt=1 (queue active)
Apr 18 08:35:08 Primary-domain postfix/pickup[1032]: 5734538B7E82: uid=0 from=<root>
Apr 18 08:35:08 Primary-domain postfix/cleanup[4977]: 5734538B7E82: message-id=20130418063508.5734538B7E82@Primary-domain.localdomain
Apr 18 08:35:08 Primary-domain postfix/error[4975]: 2339438B3344: to=<root@secondary-domain.co.za>, orig_to=<root>, relay=none, delay=38469007, delays=38469007/0.27/0/0.11, dsn=4.3.0, status=deferred (address resolver failure)
Apr 18 08:35:08 Primary-domain postfix/qmgr[1033]: 2B8B838B1CBA: from=<root@mail.secondary-domain.co.za>, size=1221, nrcpt=1 (queue active)
Apr 18 08:35:08 Primary-domain postfix/pickup[1032]: 9668238B7E83: uid=0 from=<root>

Hosts file;

127.0.0.1   localhost
127.0.0.1   Primary-domain 
127.0.0.1   mail.secondary-domain.co.za

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Main CF;

myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name
biff = no
append_dot_mydomain = no
readme_directory = no
mydestination = $myhostname, localhost.$mydomain $mydomain
relayhost = [smtp.isp-domain.co.za]:587
# smtp.secondary-domain.co.za
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mynetworks_style = host
mailbox_size_limit = 0
virtual_mailbox_limit = 0
recipient_delimiter = +
inet_interfaces = all
message_size_limit = 0

# SMTP Authentication (SASL)

smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain =

# Encrypted transfer (SSL/TLS)

smtp_use_tls = yes
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/ssl/private/ secondary-domain.co.za.crt
smtpd_tls_key_file = /etc/ssl/private/ secondary-domain.co.za.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# Basic SPAM prevention

smtpd_helo_required = yes
smtpd_delay_reject = yes
disable_vrfy_command = yes
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject

# Force incoming mail to go through Amavis

content_filter = amavis:[127.0.0.1]:10024
receive_override_options = no_address_mappings

# Virtual user mappings

alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_mailbox_base = /var/spool/mail/virtual
virtual_mailbox_maps = mysql:/etc/postfix/maps/user.cf
virtual_uid_maps = static:5000
virtual_gid_maps =  static:5000
virtual_alias_maps = mysql:/etc/postfix/maps/alias.cf
virtual_mailbox_domains = mysql:/etc/postfix/maps/domain.cf

I have tried many solutions and guides on the web of which I always seem to hit a brick wall. If there is a better setup than this to achieve my goals; of setting up a PHP mail() server with relay; please let me know.

The server has many scripts(PHP), sites and virtual domains running on it and I just need to get it to send out mail for the moment.

One of the main sites that needs to send out mail is at a virtual domain and uses the localhost mail (PHP config).

The server has also been running for more than a year; there for it is quite troublesome to figure out how it has been setup by the previous admin. Due to the content of the server and deadline; I'm not able to setup a fresh install of Ubuntu / re-install it.

share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.