This tutorial assumes that you are run XenForo on a linux server which you control and that you are comfortable in a non-gui environment. If you are running on a shared server, then it is unlikely that you will have the necessary access for mail configuration. If you aren't running on your own box with linux, stick to the normal way of doing things. If you are running your own box, and running something like cpanel, plesk, webmin or any other management layer then again it is inadvisable to go down this route, especially with cpanel.
- Compatible XF Versions:
- Additional Requirements:
- Linux O/S
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 autostartingIf you are doing other things with your email server, including sending from your web server relaying from other servers on your network, it should be fine to continue with that, that's what we do. However I make no guarantees.Code: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"
at the end of the file, add the followingCode:cd /etc/postfix sudo nano virtual
you then have to put it into readable form for postfixCode:bnc.yourdomain.com this-text-is-ignored email@example.com postmaster @bnc.yourdomain.com @bounced
Edit main.cfCode:sudo postmap virtual
and add the following to the end of the fileCode:sudo nano /etc/postfix/main.cf
Whilst in main.cf, you should also ensure the following line exists and is uncommentedCode:transport_maps = regexp:/etc/postfix/redirect.regexp myXenForoPipe_destination_rate_delay = 0s myXenForoPipe_destination_concurrency_limit = 1
Next create and edit the redirect.regexp fileCode:virtual_alias_maps = hash:/etc/postfix/virtual
and add the followingCode:sudo nano /etc/postfix/redirect.regexp
You then need to put that file into postfix readable formCode:/^.*@bnc\.yourdomain\.com/ myXenForoPipe: /^.*@bounced/ myXenForoPipe:
Now you have to edit master.cfCode:sudo postmap /etc/postfix/redirect.regexp
And add the following (including indent) to the end of the fileCode:sudo nano /etc/postfix/master.cf
Change the user to a valid user on your server, eg www-data. Also change the path in argv to match the base location of your XenForo installation, eg where index.php is located.Code: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
3 The XenForo bit.Code: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
Note that as the script expects data to be piped in, it will hang if you try and call it any other wayCode:$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