Resource icon

Amazon SES Bounces Support 2021-03-19

No permission to download

JulianD

Well-known member
JulianD submitted a new resource:

Amazon SES Bounces Support - Add Amazon SES bounce and complaint support

Amazon SES Bounces Support​

This addon creates an endpoint in your forum that will be used by AWS SNS to send notifications about bounces and complaints.

Since it doesn't creates the notification topics automatically it is your job to create them in the AWS console. Luckily enough, it consist only of a few steps detailed below.

Create SNS topic​

  • Go to your AWS Console and look for the Simple Notification Service.
  • Go to Topics and hit...

Read more about this resource...
 

Mouth

Well-known member
Add Amazon SES bounce and complaint support
[...]
This addon creates an endpoint in your forum that will be used by AWS SNS to send notifications about bounces and complaints.
Very interesting.

Could you give further information on the xF action? What does it do once the endpoint receives a notification? Does it treat bounces and complaints differently, or actions them the same?

What is the benefit over email based bounce/complaint notifications?
 

JulianD

Well-known member
Very interesting.

Could you give further information on the xF action? What does it do once the endpoint receives a notification? Does it treat bounces and complaints differently, or actions them the same?
The parser extracts the status code reported by AWS and passes it to the XenForo Bounce Processor which decides how to handle the bounce, either a hard or a soft bounce, depending on the status code (see XF\EmailBounce\Parser.php).

Complaints are treated as hard bounce since a complaint almost always means "I don't want to receive these emails anymore".

What is the benefit over email based bounce/complaint notifications?

Since the processor which handles the bounces is the same, there's no real difference for bounces. The only benefit that I see is that this addon is capable of handling both bounces and complaints.

My primary reason to build this addon is that after a few hours of fiddling with a Gmail account I wasn't able to get it to work with XenForo, so I decided to build an SNS compatible endpoint to receive bounce and complaints notification.
 

BoostN

Well-known member
Well done! I did something similar in an addon for myself, but this one a lot nicer than mine. Installing now and see how it goes. Thanks!
 

JulianD

Well-known member
How much are we talking to support this addon further?
I'm currently using it on two of my forums so I'd say pretty much supported. It's been released under MIT license as well so you can fork it and do pretty much whatever you want with the addon. It's a very simple code as of today.

How does this relate to the XF options like "bounced email address" and "Automated bounced email handler"?
Under the hood this addon applies the same logic to bounced emails. The only difference is that instead of having to configure a dedicated email address for bounces, this addon allows you to setup AWS Simple Notification Service to do that for you. It's only useful if you use AWS SES to send emails.
 

JulianD

Well-known member
Is there any way to tell if it is working?

You can configure a test user with a fake email account that you're confident will bounce and then try to send some emails using your forum. The Bounce Log will log everything that goes to the endpoint.
 

orange7

Active member
You can configure a test user with a fake email account that you're confident will bounce and then try to send some emails using your forum. The Bounce Log will log everything that goes to the endpoint.
Great thank you. Last question. Say I had my xenforo in the /forum folder. Would the endpoint need to look like this? https://www.forum.com/forum/api/amazon-ses/bounce or would I leave the /forum out of it like this? https://www.forum.com/api/amazon-ses/bounce
 

Rodolfo

Member
Many thanks for sharing this.

I had this situation when the email bounce server went off and I got a loop of 50K emails and I got suspended by Amazon within 12-hours. Thanks to your addon I can now rely in SNS for that processing which I've been also using in another (non xf) project so I know that is the best way to deal with it when using SES.
 

JulianD

Well-known member
Is there an intention for this add-on to come out of Alpha status, and be maintained (if required to remain compatible with xF versions)?
Well there hasn't been any bug reports so far, even though the addon has a good amount of precautions to detect a difference in the AWS SNS payload which is what made me release it as alpha.

I guess I'll make a future release marked as beta or even 1.0.0. As for support, as long as I'm using it in one of my XenForo communities (2 as of today), I'll keep supporting it. Besides that, the addon is fully open source (https://github.com/laneros/MailTransport) with a permissive license which allows you or anybody else to take over the addon in case I'm unable to do so in the future.

Let me know if you have any other question.
 

Solari

Active member
This will be a very useful add-on!

I followed your directions for everything, but in the topics area of Amazon SNS it says it is still "pending confirmation" of the topic created.

I can confirm the plugin is installed by going to the URL (https://forum.com/api/amazon-ses/bounce) (the forum is a root domain install so no /forum needed). Going there in the browser returns:

Code:
{
    "errors": [
        {
            "code": "no_api_key_in_request",
            "message": "No API key was included in the request.",
            "params": []
        }
    ]
}

Is there something else I need to do? Are there additional options within XF to do?

Thanks!
Ray
 
Last edited:

Solari

Active member
Weird. I deleted it and did the steps over and it worked this time. All good now.

I'm guessing I don't need to turn on bounce handling, etc. in Xenforo options since this one takes over? Does it automatically flag user accounts whose emails bounce, etc. like Xenforo does with bounce handling?

Very much appreciate you setting this up!

Thank you,
Ray
 
Last edited:

Solari

Active member
Hmm, I'm getting these errors when a bounce or complaint comes through:

  • ErrorException: [E_NOTICE] Trying to get property 'recipient' of non-object
  • src/XF/EmailBounce/Processor.php:106
  • Generated by: Unknown account
  • May 7, 2021 at 1:46 AM
Code:
#0 src/XF/EmailBounce/Processor.php(106): XF::handlePhpError(8, '[E_NOTICE] Tryi...', '/home/runcloud/...', 106, Array)
#1 src/addons/Laneros/MailTransport/Api/Controller/SnsNotification.php(45): XF\EmailBounce\Processor->processMessage('{"notificationT...')
#2 src/XF/Mvc/Dispatcher.php(350): Laneros\MailTransport\Api\Controller\SnsNotification->actionPost(Object(XF\Mvc\ParameterBag))
#3 src/XF/Api/Mvc/Dispatcher.php(27): XF\Mvc\Dispatcher->dispatchClass('Laneros\\MailTra...', 'Post', Object(XF\Api\Mvc\RouteMatch), Object(Laneros\MailTransport\Api\Controller\SnsNotification), NULL)
#4 src/XF/Mvc/Dispatcher.php(113): XF\Api\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Api\Mvc\RouteMatch), Object(Laneros\MailTransport\Api\Controller\SnsNotification), NULL)
#5 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Api\Mvc\RouteMatch))
#6 src/XF/App.php(2337): XF\Mvc\Dispatcher->run()
#7 src/XF.php(488): XF\App->run()
#8 index.php(16): XF::runApp('XF\\Api\\App')
#9 {main}

Code:
array(4) {
  ["url"] => string(22) "/api/amazon-ses/bounce"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

And

  • TypeError: Argument 3 passed to XF\EmailBounce\Processor::logBounceMessage() must be an instance of XF\EmailBounce\ParseResult, bool given, called in /home/runcloud/webapps/commentari/src/XF/EmailBounce/Processor.php on line 134
  • src/XF/EmailBounce/Processor.php:206
  • Generated by: Unknown account
  • May 7, 2021 at 1:46 AM

Code:
#0 src/XF/EmailBounce/Processor.php(134): XF\EmailBounce\Processor->logBounceMessage('{"notificationT...', NULL, false, NULL)
#1 src/addons/Laneros/MailTransport/Api/Controller/SnsNotification.php(45): XF\EmailBounce\Processor->processMessage('{"notificationT...')
#2 src/XF/Mvc/Dispatcher.php(350): Laneros\MailTransport\Api\Controller\SnsNotification->actionPost(Object(XF\Mvc\ParameterBag))
#3 src/XF/Api/Mvc/Dispatcher.php(27): XF\Mvc\Dispatcher->dispatchClass('Laneros\\MailTra...', 'Post', Object(XF\Api\Mvc\RouteMatch), Object(Laneros\MailTransport\Api\Controller\SnsNotification), NULL)
#4 src/XF/Mvc/Dispatcher.php(113): XF\Api\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Api\Mvc\RouteMatch), Object(Laneros\MailTransport\Api\Controller\SnsNotification), NULL)
#5 src/XF/Mvc/Dispatcher.php(55): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Api\Mvc\RouteMatch))
#6 src/XF/App.php(2337): XF\Mvc\Dispatcher->run()
#7 src/XF.php(488): XF\App->run()
#8 index.php(16): XF::runApp('XF\\Api\\App')
#9 {main}

Code:
array(4) {
  ["url"] => string(22) "/api/amazon-ses/bounce"
  ["referrer"] => bool(false)
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(0) {
  }
}

Let me know how I can help debug this.

Thanks!
Ray
 
Top