Home › Toolset Professional Support › [Resolved] Notification Emails not Sending but Tests are OK
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.
This topic contains 30 replies, has 3 voices.
Last updated by Nigel 7 months ago.
Ok fine.
Please see the notifications linked to this post: hidden link
This should have prompted email notifications to several users, but the mail logging has not recorded any attempt to email.
For the following post which you shared:
- hidden link
To what users you aim to send the email notification and using what Toolset form?
Have you added any related code before that sends the notification to multiple users?
These are individual posts that are offer to volunteer that are linked via relationships to the show.
The offers could have been accepted via any of the following forms:
9224, 9225, 9214, 25102 or 9194.
Most that have Volunteer Type FOH will have been added using Post Form 9214.
Each of the offers is an individual post with its own post meta and individual notification settings.
I would like to know what is the "Post expiration:" setting for number of days you set for post expiration with your form?
- hidden link
As I understand - For instance, you set the "Post expiration:" setting to Post will expire in 15 days and the email notification is set to send email to author of the offer post 36 hours before the automatic expiration date.
Is this correct? If no, please clarify to what people (as you claim you want to send email to multiple people) you want to send the email before 36 hours? Do you mean you want to send emails to all the related posts of post relationship "Shows link to Offers" for the following post?
- hidden link
The post expiration date is updated to match the time stamp of the show.
See Function in php snippets:
function save_data_form_4737($post_id, $form_data) {
// This is the form that updates Post A
if ($form_data['id']==9194||$form_data['id']==9214||$form_data['id']==9225||$form_data['id']==9224) {
$related_post_id = toolset_get_related_post($post_id, 'show-link-to-offer','parent');
$a_expiry = get_post_meta($related_post_id, 'wpcf-show-date-and-time-be', true);
// update expiry date
update_post_meta($post_id, '_cred_post_expiration_time', $a_expiry);
}
}
The notification is then sent 36 before the show date / post expiration date.
You are correct to think that I want to send emails to all the related posts of post relationship "Shows link to Offers" when the Offer is at Accepted status per the custom field in offers.
Hi
We are getting the following in the php error log file.
[20-Mar-2024 02:40:02 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /home/blackburnempire/public_html/volunteer/wp-content/plugins/cred-frontend-editor/application/controllers/expiration_manager/post/notifications.php:173
Stack trace:
#0 /home/blackburnempire/public_html/volunteer/wp-content/plugins/cred-frontend-editor/application/controllers/expiration_manager/post/notifications.php(173): count('')
#1 /home/blackburnempire/public_html/volunteer/wp-includes/class-wp-hook.php(324): OTGS\Toolset\CRED\Controller\ExpirationManager\Post\Notifications->send_scheduled_notifications()
#2 /home/blackburnempire/public_html/volunteer/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#3 /home/blackburnempire/public_html/volunteer/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#4 /home/blackburnempire/public_html/volunteer/wp-cron.php(191): do_action_ref_array('cred_post_expir...', Array)
#5 {main}
thrown in /home/blackburnempire/public_html/volunteer/wp-content/plugins/cred-frontend-editor/application/controllers/expiration_manager/post/notifications.php on line 173
If you check the file notifications.php on line 134 it has the following code:
/** * Get a list of posts that are waiting to be expired and include an expiration notification. * * @return array * @since 2.3 */ private function get_expiring_posts_with_notifications() { global $wpdb; $posts_for_notifications = $wpdb->get_results( $wpdb->prepare( "SELECT expired_post.post_id, expired_post.meta_value AS expiration_time, post_notifications.meta_value AS notifications FROM $wpdb->postmeta expired_post INNER JOIN $wpdb->postmeta post_notifications ON expired_post.post_id = post_notifications.post_id AND expired_post.meta_key = %s AND post_notifications.meta_key = %s WHERE expired_post.meta_value != 0 AND expired_post.meta_value IS NOT NULL", array( SingularPostExpirationManager::POST_META_TIME, SingularPostExpirationManager::POST_META_NOTIFICATION, ) ) ); return $posts_for_notifications; }
It tries to find all posts where notifications are set.
When I try to run the query on database using using the admirer plugin (which I added on your install):
SELECT expired_post.post_id, expired_post.meta_value AS expiration_time, post_notifications.meta_value AS notifications FROM sc_postmeta expired_post INNER JOIN sc_postmeta post_notifications ON expired_post.post_id = post_notifications.post_id AND expired_post.meta_key = '_cred_post_expiration_time' AND post_notifications.meta_key = '_cred_post_expiration_notifications' WHERE expired_post.meta_value != 0 AND expired_post.meta_value IS NOT NULL
I see the notification column has no value in it:
- hidden link
That is why you see the fatal error. As I do not know the site history, is it ok to delete those records which do not have notification?
We have deleted all the records with nothing in the notification column, which has corrected the php error log.
We have noticed that the reminders are now being sent but NOT 36 hours before the event, but appear to be random times approximately 24 hours before the notification expiry date.
You can see these on the SMTP Post logs. They can be anything from 3 hours before the date to over a month before the date.
See the email in the log dated March 26, 2024 2:40 pm which sent the reminder notification over a month before the show.
See the email in the log dated March 26, 2024 2:40 pm which sent the reminder notification over a month before the show.
===>
Can you please create a brand new post and make sure that the correct custom post expiration date is set and then check the notification and see when the notifications are send for this brand-new post.
The emails are going out but at very strange times.
We created a brand new test show set for 02/04/24 at 8pm and the email arrived at 15:40GMT. 7h40m after it should have arrived.
We had a show on at 3pm on 02/04/24 at 3pm and the emails for that show went out at the exact same time as the test show email. Exactly 3:40pm GMT.
It definitely isn't using the 36 hours before system and is just sending them at 3:40am and 3:40pm regardless of when the show is.
If the post expiration date value is stored correctly that means its saved with the correct Timezone with no time difference.
Do you see any different in date value?
I got the information that "Notifications" are based on WordPress scheduled events, which are not true CRON jobs, and are only triggered when there is activity on the site. If there is no activity it will not send notification.
In your case if a notification was sent 7 hours later than expected, it could be because there was no activity for 7 hours after the time when the notice should have actually been sent. Can you confirm this?
Hi Minesh,
There should be activity during the evening and I can't see any reason there would be any activity at 3am. The emails continue to go out at 3:40pm and 3:40am precisely which is definitely not 36 hours before 7:30pm. Everything looks correct and we cannot solve this.
Can I've another test site on the same server so I can setup a demo to check what's going wrong as I just checked with my local test install and the notification setup works as expected.
I will try to setup the basic demo and see how it goes.
I have set the next reply to private which means only you and I have access to it.
Before we try that.
I have installed Wp Crontrol and cannot see any cron jobs for Email notifications.
Should a cron job be running for these notifications to work correctly? If so, what is it?