- Compatible XF 1.x versions
- Additional requirements
Not Shared server
There are three components to this, Networking, mail config and XenForo changes.
1. Networking. A domain will need to have its MX record pointing at this box. It needn't be, in fact it shouldn't be the domain of your installation, it can however be a subdomain, so if your domain is myforum.com. Set up some subdomain like b.myforum.com and point your MX record for that at your forum web server. How do you setup an MX record? It depends on the provider doing your DNS hosting, you'll have to refer to them. You'll also need to allow incoming traffic on port 25 to your web server.
2. Mail Configuration. On our server, we have gone for postfix, although no doubt this could be done with sendmail as well. You'll have to check what mail server, if any is installed. Commonly sendmail is installed and postfix isn't. Use your package manager to install postfix (eg sudo yum install postfix or sudo apt-get install postfix). Dont forget to turn off Sendmail and stop it from autostarting
sudo service sendmail stop && sudo chkconfig sendmail off
To configure postfix you need to do the following. In this tutorial I am using the domain "bnc.yourdomain.com" - replace this with whatever domain you are using. In this example we are going to use a 'transport map' to define a rule as to how email will get handled when sent. There are other ways of achieving the same result, but ths worked for me.
Add domain to your mail server by editing "virtaul"
cd /etc/postfix sudo nano virtual
bnc.yourdomain.com this-text-is-ignored firstname.lastname@example.org postmaster @bnc.yourdomain.com @bounced
sudo postmap virtual
sudo nano /etc/postfix/main.cf
transport_maps = regexp:/etc/postfix/redirect.regexp myXenForoPipe_destination_rate_delay = 0s myXenForoPipe_destination_concurrency_limit = 1
virtual_alias_maps = hash:/etc/postfix/virtual
sudo nano /etc/postfix/redirect.regexp
/^.*@bnc\.yourdomain\.com/ myXenForoPipe: /^.*@bounced/ myXenForoPipe:
sudo postmap /etc/postfix/redirect.regexp
sudo nano /etc/postfix/master.cf
myXenForoPipe unix - n n - - pipe flags=O user=nginx argv=/path/to/php /path/to/forum/base/emailbounce.php
All done- you just need to stop start postfix
sudo service postfix restart
The attachment is a single file, emailbouce.php.zip, and this should be unzipped and placed in the root of your installation , alongside index.php and admin.php. The file itself is a copy of deferred.php with a few changes including:
* Removal of the deferred functionality
* A check to ensure that this can only be run from the command line
* A line to capture piped input (the email) into a variable ($data = file_get_contents("php://stdin"))
* Execution of standard XenForo bounce processing
$emailModel = XenForo_Model::create('XenForo_Model_EmailBounce'); $emailModel->processBounceEmail($data);
"php emailbounce.php" = bad
"echo data|php emailbounce.php" = good
I always advise checking for an open relay after reconfguring an SMTP server. If you inadvertantly turn on open relay for your SMTP server, you'll probably get abused by spammers. To test, go to http://www.dnsgoodies.com/ and do the Openrelay check