Skip Navigation

[Resolved] E-mail notifications not sending

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 15 replies, has 2 voices.

Last updated by ricardoL-4 3 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1687449

Tell us what you are trying to do?
I have some custom post types and I want to send reminder e-mails to post authors before the expiration date. So I created a post form with expiration date and created an email notification with 1 minute before the expiration date. Then, I did some tests on my website and I can send test emails on the form, but I can't received any emails before the post expiration date. My concern/question:

1. I might be doing something wrong and that's why isn't working.
2. There is a cron hook that it's not working properly?

Do you think you can have a look?

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/unable-to-edit-form-because-there-has-been-a-critical-error-on-your-website/

#1688163

Hi, Forms notifications are sent out using the WordPress cron, which isn't a true cron. A true cron is triggered every (n) seconds or minutes or hours or at a specific time, regardless of site activity. WordPress doesn't work that way. Its internal cron must also be triggered by interaction on the site, whether that is someone using wp-admin or someone hitting a page on the front-end of the site - any action that requires some WordPress request. So if you set up a post that expires in 2 hours on your local test site, then take a break for 3 hours and expect to receive a notification before post expiration, you probably won't get one unless your local test site is being actively used by others during your break. WordPress didn't run for 3 hours and the expiration is over an hour old by the time WordPress has been triggered again by your browser. So when you hit the site again after a 3 hour break, the cron task runs but it notices the scheduled time for that action was an hour ago and the notification isn't sent.

This is what I suspect is happening, especially if you're not working with a live site or you've had posts expire in the middle of the night or something similar. On your live site, you can ask your host to help set up a true server-based cron that loads the homepage URL every few minutes regardless of site activity, and that would automatically trigger the WordPress cron periodically to send out any queued up notifications. This way if the site sits without any use for a long period of time, any queued notifications will still be sent as expected.

There are also some quirks regarding the timezone display settings and the expiration time selected in Forms, so that can be confusing. With this information in mind, I'll be glad to take a look if you think the WP cron isn't working as expected. Please provide login credentials here in the private reply fields and let me know which Form and notification I should check.

#1688203

When I try to log into the WP dashboard using these credentials, unfortunately I'm seeing an error that the password for this username is incorrect. Can you double-check? I will reactivate private fields in case you need to share a different login.

I'll take a quick look and see if I can figure out why it's not possible to edit the Form. If it's not obvious, I may need to open a separate ticket to investigate that before we can move forward with the notification investigation.

#1690651

Okay I suggest setting the email notification to something like 5 minutes before expiration, this way the Toolset Forms cron has several opportunities to run between the time the notification should be sent and the time of expiration. This will help ensure the notification is sent out. I also see the expiration is set to 30 days after publication, which isn't really practical for testing. If it's okay with you, I would like to change that to 1 day after post publication, update the timing to 5 minutes before expiration, and submit the Form on your live site a few times to test it out. Is that okay? Should I remove the ...moes@gmail email address while testing?

#1690653

I understand.
Yep, you can do all that you said 🙂

#1691849
Screen Shot 2020-07-08 at 11.38.06 AM.png

Okay about 2 hours ago I published a post on the live site, and I set the expiration to 2 hours from publication date. Here are the post URLs:
Front-end - hidden link
In wp-admin - hidden link

Around 1 hour and 52 minutes later, I began refreshing some pages on the site so the cron would be triggered. Right on time, I received the email notification in my inbox, and I'm attaching a screenshot here. The post I published is also set to Draft status correctly. So the notification and expiration all seems to be working as expected in this test. I have updated the email notification settings to reflect the original recipients. Feel free to adjust the other settings as needed.

Again, the cron must be triggered by some use of the site. So I suggest asking your live site host to set up a true cron that loads the homepage every minute, since the Toolset Forms cron settings are configured to run every minute. This will trigger the WordPress cron, and Forms notifications and post expirations will be triggered effectively.

#1692863

Ok, I did some tries but unfortunately doesn't work if the website is indeed not active. I tried to add by my self the cron job but I don't know if I'm using the right code and the guys from HostGator tell me to hire a developer for that...

I know this is beyond your support, but do you know if this code is the right one to use on the cron job:
/usr/bin/php /home2/docemass/public_html/mysite/index.php > /dev/null 2>&1

Thank you in advance?

#1695369

I'm really not sure. Serverside scripting is not really one of my specialties and the syntax and commands depend on the server, the command-line options available, the hosting environment and path structure, etc. It looks good enough to try 🙂 Surely there is an FAQ somewhere on their site where you can find an example.

#1702831

Hi, well I guess it worked.
Anyway, I'm still struggling with the emails so I have some questions...

1- When you say: "Okay about 2 hours ago I published a post on the live site, and I set the expiration to 2 hours from publication date." ...do you mean you created the post directly on the back office of the Custom Type and you manually added 2 hours?
2 - If I have a post with an expire date and I changed the date, does the emails are send too?
3 - I have 2 post forms. One to create a post and another to edit post. Are emails sent independently from each post form?
4 - If I have a form with a post expiration of 30 days, and if I change the expiration date of the published post directly on the back office, for a couple of days ahead, will it count and send the email notifications too?

Sorry, for all theses questions.. I've been trying to understand how it works the email notifications and even tho I have refreshing the page, I don't get any emails... so I assume I'm doing something wrong 🙂

Thank you in advance!

#1703529

So, I did a few more tests and I realise a few more things (please correct me if I'm wrong):

This is what I want to do:
I want to have posts where users can make changes, but I don't want them to change the expiration date.

This is what I did:
I created 2 forms for my custom post type. One to add a post with the expiration date on; and another to edit the post without expiration date, so when the users update their post the expiration date stays intact as when the post was created.
It works fine this way and it sends all the emails I had on the add form.

My issue are these scenarios:
1- If a user edits the post, are all the email notifications replaced to the edit form? ...and since I don't have any expire date on the edit form, I can't send any emails saying the post will expire in X days..?

2- If I have to edit the post in the backend, including the expiration date, does it sends anyway the email notifications?
3- If a post expires and goes to draft and later I want to publish it with a new expiration date, will any email notifications be active? ..if yes, from witch post form - add or edit ?

Having this issues in mind how you suggest me to workaround them?

Thanks!

#1705253

1- When you say: "Okay about 2 hours ago I published a post on the live site, and I set the expiration to 2 hours from publication date." ...do you mean you created the post directly on the back office of the Custom Type and you manually added 2 hours?
No, I mean I modified the expiration date in the Form settings, then I published a post through the Form. I did not manually change th expiration date after posting.

2 - If I have a post with an expire date and I changed the date, does the emails are send too?
If you manually change the expiration date of a post after it is published, any email notifications triggered by the expiration date will be triggered by the new expiration date, not the original expiration date.

3 - I have 2 post forms. One to create a post and another to edit post. Are emails sent independently from each post form?
I don't really understand the question, could you provide more details to explain the situation?

4 - If I have a form with a post expiration of 30 days, and if I change the expiration date of the published post directly on the back office, for a couple of days ahead, will it count and send the email notifications too?
Yes, this is basically the same as question #2, right? Or am I misunderstanding one of these questions?

I will try to answer the following set of questions shortly, please stand by.

#1707777

Thank you Christian, I understand your explanation. But I still interested about one issue that I asked you before which is:
I want to have posts where users can make changes, but I don't want them to change the expiration date.
So I created 2 forms for my custom post type. One to add a post with the expiration date on; and another to edit the post without expiration date, so when the users update their post, the expiration date stays intact as when the post was created.

My issue are these scenarios:
1- If a user edits the post, are all the email notifications replaced to the edit form? ...and since I don't have any expire date on the edit form, I can't send any emails saying the post will expire in X days..?

2- If a post expires and goes to draft and later I want to re-publish it with a new expiration date, will any email notifications be active? ..if yes, from witch post form: add or edit form ?

thank you

#1708167

1- If a user edits the post, are all the email notifications replaced to the edit form?
The original email notifications from the original Form are still applicable, and any notifications you create with the edit Form are also applicable. The Edit Form does not cancel any existing notifications, if that's what you mean. I don't think I fully understand the question, maybe you could explain a specific scenario for me?

.and since I don't have any expire date on the edit form, I can't send any emails saying the post will expire in X days..?
The expiration date settings are relative to the publish date of the post, not the update date. So if you want to keep the same expiration that was originally used, set the expiration on the Edit Form identical to the Create Form.

2- If a post expires and goes to draft and later I want to re-publish it with a new expiration date, will any email notifications be active? ..if yes, from witch post form: add or edit form ?
Are you talking about notifications triggered by expiration? If so, any notification should only run once in any case, it won't be re-run if the post is republished. So let's say there is a notification triggered 1 hour before expiration, and it was created by the Add Post Form. 1 hour before expiration, the notification is sent. Then the post expires and goes to Draft, but an admin republishes the post in wp-admin. The expiration triggered notification isn't re-created or re-scheduled again for the next expiration time.

Maybe I need to understand the scenario in more detail - who is publishing the post, are they publishing using Forms or in wp-admin, what is the notification trigger, etc.

#1712791

Ok, I think I understand now how the email notifications work.

So I was wondering, is there a way to have a costume code for:
1- when a user edit post forms don't trigger any email, and it keeps valid the emails trigged by the add post form?

and another custom code for:
2- When post goes to Draft, but an admin republishes the post in wp-admin, can emails be trigged with that action?

thanks

#1713057

1- when a user edit post forms don't trigger any email, and it keeps valid the emails trigged by the add post form?
There's no need for custom code here if you configure the edit post Form to send no automatic notifications. Are you saying you want a way to toggle the edit post Form's notifications on and off using custom code? You can conditionally send notifications using custom code as described in the following ticket: https://toolset.com/forums/topic/cred-form-notification-email-conditional-on-generic-field/

2- When post goes to Draft, but an admin republishes the post in wp-admin, can emails be trigged with that action?
No, unfortunately Forms automatic notifications must be triggered by Form interaction. There are no external API triggers available for Forms notifications. You could set up multiple Edit Post Forms - one for Admin interaction and another for non-Admin interaction, and trigger different notifications for each Form. You can use conditionals or Access shortcodes to display different Forms to different Users based on User role.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.