Mautic Community Forums

Bounce and Complaint Notification Handlers

Hey Dev Team,



I am looking for Bounce and Complaint notification handlers, for Mautic. This Bounce and Complaint file should handle and process the hard bounce, soft bounce and spam complaint from the emails and should automatically remove those emails from active email list. This help the marketer to keep the email list clean and updated. Finally, having this feature, it will avoid sending email on bounced email again and again.



Having this feature, need to use notification services from SMTP providers. For instance, Amazon SES uses Amazon SNS service to notify about the bounce and complaint to the email list, similarly, Mandrill uses Webhook to implement this facility.



So, let me know, if this feature is on the list of development?

Hey Dev Team,

I am looking for Bounce and Complaint notification handlers, for Mautic. This Bounce and Complaint file should handle and process the hard bounce, soft bounce and spam complaint from the emails and should automatically remove those emails from active email list. This help the marketer to keep the email list clean and updated. Finally, having this feature, it will avoid sending email on bounced email again and again.

Having this feature, need to use notification services from SMTP providers. For instance, Amazon SES uses Amazon SNS service to notify about the bounce and complaint to the email list, similarly, Mandrill uses Webhook to implement this facility.

So, let me know, if this feature is on the list of development?

We are in the process of adding the Mandrill webhook function right now. Check this out:

https://github.com/mautic/mautic/pull/429

Hopefully Amazon will be supported as well soon. Is there something else supported for general SMTP servers that’s a ‘standard’ callback location we can try to support?

Hey Chad,

This looks good. And the process would be similar for Amazon SES / SendGrid / MailGun too.
But, what about processing and removing of bad emails from Mautic email list?

So we take Mandrill’s post back if its a bad email and we update the lead info so we don’t keep trying to email that lead.

There’s some other features that might be nice like an email health-management API. We’ve seen some suggestions to do that but haven’t gotten that far yet.

For now, Mandrill is totally supported with the webhooks and we’ll keep trying to add more providers!

I’ve been trying to get the Amazon SES bounce and unsubscribe functional but I haven’t been able to get this right. Has anyone developed a tutorial on this? When might Amazon be supported directly? Am I missing something?

For some reason, while I’m using the latest version of mautic where the above pull request had been updated. I’m unable to get mautic to read and mark the bounced on the system. I have manually moved the bounced emails into a folder and marked it on the “Email” Settings tab and made sure all is marked as unread. This is still not happening.

My Cron Jobs are configured to run every 5 minutes.

Any idea what might be going wrong?

Hello:
I have not been able to get my bounces from Amazon to function right. Amazon delivers the notification to a unique email address which has been configured in the settings tab. The emails are being read from that fiolder…at least I think so because when I depress the test button all checks out ok. Or at least the message return “success”

I see a number of folks have this issue. Is it advisable to follow the suggestions by Karan on this post

It is relatively recent but I do not see anybody else suggesting it works. If the developers here suggest this is a valid fix I will move forward and test it out. With one question. Karan has a line of code that says “emailAddress”:"someemail@somehere.com" . Is this supposed to be the email address
where ethe Amazon bounce notifications are sent and subsequently retrieved from?

Thanks, Rich

UPDATE: I wanted to confirm cron was not the problem with the bounced emails so I made sure all of the bounce notification email from Amazon were unread. I waited for the cron to execute and when it fired, all the emails turned to “Read”. This suggests the cron is firing and Mautic is reading the email box, however; it does not process the emails (it does not mark the contact as do not contact)

Hello, I am not sure if Karan solution works. I’ve made my own which is working for me. I’ve made a pull request:
https://github.com/mautic/mautic/pull/1829

After changing the code you have to run (unless you have it as a cron job): php app/console mautic:fetch:email

If you want to add unsuscribed or bounces to a Segment you will also need to follow this pull request: https://github.com/mautic/mautic/pull/1836

I made modifications in the MessageHelper.php and it got working for SNS. The current MessageHelper.php does not support messages from SNS.

Add the following to the lines as shown and it will work

On Line 98:
/* PROCESSING FOR AMAZON SNS /
$hashId = ‘’;
if (preg_match(’/+([a-zA-Z]
)_([0-9a-zA-Z])@/’, $message->textPlain, $parts))
{
print_r($parts);
if($parts[1] == ‘bounce’)
{
$isBounce = true;
$isUnsubscribe = false;
}
else if($parts[1] == ‘unsubscribe’)
{
$isBounce = false;
$isUnsubscribe = true;
}
$hashId = $parts[2];
}
/
PROCESSING FOR AMAZON SNS */

after adding the above go to line 518 and add the following

	/* PROCESSING FOR AMAZON SNS */		
    /*
    * rule: mailbox error (Amazon SNS);
    * sample:
	{"notificationType":"Bounce","bounce":{
	,"bounceType":"Permanent",
	"emailAddress":"someemail@somehere.com"
	}
	}
    */
    elseif (preg_match('/"emailAddress":"([a-zA-Z0-9-_@.']*)"/', $body, $match)) {
        $result['rule_cat'] = 'unknown';
        $result['rule_no']  = '0013';
        $result['bounce_type'] = 'hard';
        $result['remove']      = 1;                 
        $result['email']    = $match[1];
		print_r($result);
    }
	
	/* PROCESSING FOR AMAZON SNS */

Same problem with amazon SES here. Its all setup properly, cron’s, email confirmation, but Mautic is not processing the notifications that Amazon SES is sending.

The main issue I have with Mautic is that it’s currently lacking the ability to configure an HTTP/HTTPS “Endpoint” URL via Amazon SNS (which is similar to Mandrill’s Webhook URL) in order to trigger the bounce/complaint events automatically without using a mailbox.

But, in order to have Amazon SNS send these actions to an email, you could do the following:

  1. Go to your Amazon SNS console, click Topics on the left sidebar, then click the Create new topic button and name it something like ses-bounces (leaving Display name blank), then click the Create topic button

  2. Select the ses-bounces topic you just created, then click the Actions button, then click Subscribe to topic

  3. Now you need to select Email as the Protocol and populate the Endpoint field with the email you want to use to receive the bounces. Click the Create subscription button and check that email address in a few seconds/minutes to confirm the subscription.

  4. Go to your Amazon SES console > Verified Senders > Email Addresses and click on the email you will be using (or create and verify the email you’ll use for sending). If you verified a domain, go to Amazon SES console > Verified Senders > Domains and click on the domain you attempted to verify.

  5. Under ‘Notifications’, click Edit Configuration

  6. Under ‘SNS Topic Configuration’, click click the Bounces drop down menu and select ses-bounces (which was the topic you created in step #1 through your SNS console)

Repeat the same steps for complaints. You’ll also need to go though all the steps for every single domain/email you verified for sending via Amazon SES.

@carlos thank you for this.

I previously had bounces working extremely well with Mandrill/Mautic setup. But as Mandrill have changed their user policy I moved to AWS SES.

I am not sure if I have missed anything however, I followed all the steps above for SNS via AWS and SES. (note I tried leaving the default notification “via email” in SES and nothing was happening at all - no forwards of bounced emails were being received at the sending email address used in Mautic- SNS seems to be the only viable option)

So I followed your steps (big thanks) -to set up SNS for bounced and complaints - and then changed notifications in SES to use the SNS for the domain and emails for that domain. So far so good.

I can confirm that the bounced and complaints SNS notifications ARE being delivered to the correct destination email inbox so I know I have set up SES /SNS correctly. Thats a BIG Tick :slight_smile:

The issue I am having is that Mautic does not seem to be retrieving the bounced emails from the designated email address specified in the email settings in the mautic configuration page. I have tested the email config via mautic and it sees the destination email and retrieves the folders. So I do know that this is set up correctly in Mautic to look at the correct email address to retrieve the bounced emails.

As stated - Previously I had bounces successfully working with Mandrill/Mautic and I could see the bounced emails being added to the smartlist.

With the AWS SES/SNS method I can’t see the bounced emails being added to the bounced email list (using smart list email =bounced) and if i look at individual clients that I can see have had a bounced email (i.e in check the email inbox and look at the from email address then cross reference to the mautic clients to find the record) they are not being flagged as bounced against their record in MAUTIC.

I have not changed the fetch email cron job since I switched from mandrill to SES but have checked and it appears to be OK.

I have also manually run the cron job and can see that the cron job DOES appear to process the bounced emails. Its just that these records are not then being flagged in Mautic.

Is there anything to do with the structure of the email received from SES vs the email received from Mandrill? What exactly is mautic looking for in the email when determining if the email is a bounced email

Is there something different I have to do in mautic to get this to work so that it reads in the emails , identifies the bounce and then flags this against the record as bounced?

Any additional feedback would be awesome. I feel it’s so close, there’s just something not quite right somewhere.

Many thanks