How to Get Notified if Email Alerts Failed to Send

Last Update: November 11, 2016

This is guide that will help you setup an external notifier if your JotForm email alerts failed to sent. 

Please note that this is for advance users or who are familiar with programming. 

Here are the requirements and steps needed to be followed:

1. You need to have a server that runs PHP where you can execute the PHP script. Please consult your web hosting service for this.

2. We will need to use PHPMailer to send the notifier using your email's SMTP. Here's the official Github page of PHPMailer: https://github.com/PHPMailer/PHPMailer. You'll need to consult your email service provider to get your SMTP details. If you have a Gmail account, you can follow this guide and use that instead: Gmail's SMTP Settings

3. Our script will use both the PHPMailer and JotForm's API. What happens is that our script will check the mail log of your account and compare the submission ID of the form submitted to see if the email alerts where successfully sent. You can check JotForm's PHP API library here: JotForm API PHP Library 

4. You can then copy the PHP script I made on this link: Email Status Checker PHP Script. This is what triggers the external email notifier to send. 

5. In the PHP script, you need to setup a few things, first you need to use your API key here:

 

6. After that, make sure to fill out the necessary SMTP details in the PHP script. You need to fill out the host, port, your username, password, recipient address, etc...

 

7. You can then edit the text that will be displayed after the script is executed. Or you can also redirect the user to another link. The body of the email can be edited here:

 

8. Now make sure to enable the "Send POST Data" in your Preferences setting. 

Click "Advanced" tab and click "Show More".

Here you need to enable the "Send Post Data" option to "Yes".

9. Now placed the link of your PHP script to your "Thank You" settings:

Paste the path of your PHP script here.

 

10. Here's an example of how this works:

A user submits your form.

 

The user will then be redirected to the PHP script and it will execute it. The script will check if there are failed email alerts on that specific submission. In my case, I'm printing the details of the email alert that failed. You can of course change this message or redirect the user to another link. Below you can see that my autoresponder failed because the email address I entered is test@test.com which is not valid.

If there was indeed an email alert that failed, then it will notify the recipient email address you setup in the SMTP in our PHP script. In my case, this is how it looks like:

 

You can edit the body of the email. 


You now have a script that notifies you if any of your email alert fails. In case you find failed email alerts, you can check this section on how to troubleshoot email problems: Guides: Email Problems

If you have any questions, feel free to leave a comment below or you can open a new thread in our forum.



Send Comment