Resource icon

How to setup email bouncing via a script 2014-11-30

No permission to download

Jim Boy

Well-known member
Jim Boy submitted a new resource:

How to setup email bouncing via a script - bypass the need to manage mailboxes

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...

Read more about this resource...
 
@Jim Boy

The edit to /etc/postfix/master.cf, really should be:
Code:
myXenForoPipe unix - n n - - pipe
  flags=O user=nginx argv=/path/to/php /path/to/forum/base/emailbounce.php

And you probably want to append the following to /etc/postfix/main.cf to rate limit and limit the number of instances used:
Code:
myXenForoPipe_destination_rate_delay = 0s
myXenForoPipe_destination_concurrency_limit = 1
 
tA for the
@Jim Boy

The edit to /etc/postfix/master.cf, really should be:
Code:
myXenForoPipe unix - n n - - pipe
  flags=O user=nginx argv=/path/to/php /path/to/forum/base/emailbounce.php

And you probably want to append the following to /etc/postfix/main.cf to rate limit and limit the number of instances used:
Code:
myXenForoPipe_destination_rate_delay = 0s
myXenForoPipe_destination_concurrency_limit = 1
Ta, postfix isn't really a strength of mine. In the php script I use, I had made it executable (eg #!/usr/bin/php on first line) so it was working fine for us.
 
  • Like
Reactions: Xon
Would you be willing to explain the benefits of doing this? What is it for?
It allows for faster bounce handling, and permits the bounce emails from actually being sent off your outbound email server thus saving money if you are using a 3rd party gateway.

It means you don't need to poll a mailbox every hour, you process the messages as they arrive with built-in queuing by the email server.
 
XF2 version of the emailbounce.php script;

PHP:
<?php
if (PHP_SAPI != 'cli')
{
    exit();
}

@set_time_limit(5);
ignore_user_abort(true);

$dir = __DIR__;
require($dir . '/src/XF.php');

XF::start($dir);
$app = XF::setupApp('XF\Pub\App');

if (\XF::$versionId == $app->options()->currentVersionId || !$app->config('checkVersion'))
{
    $result = null;
    $data = file_get_contents("php://stdin");
    $app->bounce()->processMessage($data, $result);
}
 
Top Bottom