emailing of notifications
Quote from ray on November 28, 2018, 9:26 amI’m having trouble with sending out of email notifications.
At the moment I think it is a server issue rather than an email one (I use an external SMTP provider who promises to deliver all emails I submit to them).
It seems I am running foul of the 504 gateway time out error. My first guess is some sort of php (perhaps) execution timeout on my server.
Why am I thinking this? well twice in a row I had 59 ‘new topic’ notifications sent by wordpress but a slightly different 59 for each of the notifications. I think I should be sending about 100 notifications (the default on my members only site is that all members get notified of new topics – so about 100 members should be about 100 emails). So if 59 out of 100 are going out then maybe its the sending of the email that is timing out.
So I’m wondering just how the code works? Does 100 emails mean a php loop calling wpmail 100 times? So I’m getting a php exectuon time out on my server after 59 loops? I’m suspicious of a php execution time out as I have had them before on my host. So I’m looking for ammunition before i tackle the host support team.
I’m having trouble with sending out of email notifications.
At the moment I think it is a server issue rather than an email one (I use an external SMTP provider who promises to deliver all emails I submit to them).
It seems I am running foul of the 504 gateway time out error. My first guess is some sort of php (perhaps) execution timeout on my server.
Why am I thinking this? well twice in a row I had 59 ‘new topic’ notifications sent by wordpress but a slightly different 59 for each of the notifications. I think I should be sending about 100 notifications (the default on my members only site is that all members get notified of new topics – so about 100 members should be about 100 emails). So if 59 out of 100 are going out then maybe its the sending of the email that is timing out.
So I’m wondering just how the code works? Does 100 emails mean a php loop calling wpmail 100 times? So I’m getting a php exectuon time out on my server after 59 loops? I’m suspicious of a php execution time out as I have had them before on my host. So I’m looking for ammunition before i tackle the host support team.
Quote from Asgaros on November 28, 2018, 10:54 amHello @ray
Yes, currently there is a loop which is sending an email for each recipient because every recipient gets a slightly different mail (for example the username changes to make it more personal and other things which depends on your mail-template). You can contact your provider so they can check if there is a way to increase the speed between the server-components.
Otherwise if this is not possible I guess that a database and cronjob setup is necessary which saves all mails in the database and sends them continuously over time instead of directly during the content-creation. This solution will be really complex and cannot just get integrated into the plugin via a simple five-lines-of-code patch. Maybe there are already some good mailer-plugins for WordPress out there which hook into the mailing-function and bring this kind of functionality.
Hello @ray
Yes, currently there is a loop which is sending an email for each recipient because every recipient gets a slightly different mail (for example the username changes to make it more personal and other things which depends on your mail-template). You can contact your provider so they can check if there is a way to increase the speed between the server-components.
Otherwise if this is not possible I guess that a database and cronjob setup is necessary which saves all mails in the database and sends them continuously over time instead of directly during the content-creation. This solution will be really complex and cannot just get integrated into the plugin via a simple five-lines-of-code patch. Maybe there are already some good mailer-plugins for WordPress out there which hook into the mailing-function and bring this kind of functionality.
Quote from ray on November 28, 2018, 11:16 amHi
Yes I fully understand and you have confirmed my thoughts. I definitely want to avoid cron jobs. So of to my host to see if I can get php execution time increased. But being a shared host I don’t like my chances. So maybe the end result will be – no notifications at least while I have my current hosting constraints.
I’m frustrated at not being able to find a workable solution (without paying a heap of $’s) to what I think must be a ‘generic’ problem throughout the wordpress world.
slightly of topic but yet related q”s
Once registered in WP a user becomes a ‘normal’ user in the forum. So I think notifications are sent to all ‘normal users’i f they subscribe to forums or topics. So I think i have a problem in that I have a small number of members (ie ‘normal users’) who are WP registered (for admin reasons – and they never login) but have an invalid email address (to satisfy WP). So my problem would be email bounces from these fictitious email address. Is this correct – just to confirm I need to be aware of it.
What happens if a ‘normal user’ subscribes to some things and then gets ‘banned’. Do they continue to receive emails? If not then I have a work around for my fictitious email address users.
Is there any way I can join a subscription AND being a member of a user group (or preferably a custom WP role) so that emails are only sent to those who subscribe and remain a member of the user group (or role)?
Hi
Yes I fully understand and you have confirmed my thoughts. I definitely want to avoid cron jobs. So of to my host to see if I can get php execution time increased. But being a shared host I don’t like my chances. So maybe the end result will be – no notifications at least while I have my current hosting constraints.
I’m frustrated at not being able to find a workable solution (without paying a heap of $’s) to what I think must be a ‘generic’ problem throughout the wordpress world.
slightly of topic but yet related q”s
Once registered in WP a user becomes a ‘normal’ user in the forum. So I think notifications are sent to all ‘normal users’i f they subscribe to forums or topics. So I think i have a problem in that I have a small number of members (ie ‘normal users’) who are WP registered (for admin reasons – and they never login) but have an invalid email address (to satisfy WP). So my problem would be email bounces from these fictitious email address. Is this correct – just to confirm I need to be aware of it.
What happens if a ‘normal user’ subscribes to some things and then gets ‘banned’. Do they continue to receive emails? If not then I have a work around for my fictitious email address users.
Is there any way I can join a subscription AND being a member of a user group (or preferably a custom WP role) so that emails are only sent to those who subscribe and remain a member of the user group (or role)?
Quote from ray on November 29, 2018, 4:36 amI suspect others will encounter mail delivery problems as their forums grow ( I think I have a very small forum)
I’m wondering if you would build (or perhaps already have) some sort of debug functionality for us to use. I envisage doing everything except actually sending the email but writing a log file with addressee,subject, etc info by setting a debug option on/off in the forum settings. Perhaps even some time stamping (eg begin, end of loop) but I don’t really know what would be easy to do. Then in my case I would know if 59 or 100 emails were actually processed by WP and if I still have delivery issues then it would be within the email server delivery area rather than WP code (timing out without informative diagnostic errors for instance)
I suspect others will encounter mail delivery problems as their forums grow ( I think I have a very small forum)
I’m wondering if you would build (or perhaps already have) some sort of debug functionality for us to use. I envisage doing everything except actually sending the email but writing a log file with addressee,subject, etc info by setting a debug option on/off in the forum settings. Perhaps even some time stamping (eg begin, end of loop) but I don’t really know what would be easy to do. Then in my case I would know if 59 or 100 emails were actually processed by WP and if I still have delivery issues then it would be within the email server delivery area rather than WP code (timing out without informative diagnostic errors for instance)
Quote from Asgaros on November 30, 2018, 3:35 pmHello @ray
What happens if a ‘normal user’ subscribes to some things and then gets ‘banned’. Do they continue to receive emails?
Yes, currently they still receive mails even when they are banned.
So my problem would be email bounces from these fictitious email address. Is this correct – just to confirm I need to be aware of it.
I guess mails which cant get delivered get returned via an error-notification to your server. But this should not affect or slow-down the mail-function in WordPress itself – see the following description of the official wp_mail function:
“A true return value does not automatically mean that the user received the email successfully. It just only means that the method used was able to process the request without any errors.”
So basically to mail-function only forwards the mail-request to your mail-server (which sends back an “okay”) but does not wait for a successful delivery.
Is there any way I can join a subscription AND being a member of a user group (or preferably a custom WP role) so that emails are only sent to those who subscribe and remain a member of the user group (or role)?
This should be possible via hooks but I think this would slow down things even more because of additional database-queries and checks.
I’m wondering if you would build (or perhaps already have) some sort of debug functionality for us to use.
There is no integrated debug-method available yet. Have you tried to turn on the debug-mode of WordPress? It allows you to get a log-file of all errors that happens during the execution of a script:
https://wp-staging.com/docs/enable-wordpress-debug-log-mode/
Hello @ray
What happens if a ‘normal user’ subscribes to some things and then gets ‘banned’. Do they continue to receive emails?
Yes, currently they still receive mails even when they are banned.
So my problem would be email bounces from these fictitious email address. Is this correct – just to confirm I need to be aware of it.
I guess mails which cant get delivered get returned via an error-notification to your server. But this should not affect or slow-down the mail-function in WordPress itself – see the following description of the official wp_mail function:
“A true return value does not automatically mean that the user received the email successfully. It just only means that the method used was able to process the request without any errors.”
So basically to mail-function only forwards the mail-request to your mail-server (which sends back an “okay”) but does not wait for a successful delivery.
Is there any way I can join a subscription AND being a member of a user group (or preferably a custom WP role) so that emails are only sent to those who subscribe and remain a member of the user group (or role)?
This should be possible via hooks but I think this would slow down things even more because of additional database-queries and checks.
I’m wondering if you would build (or perhaps already have) some sort of debug functionality for us to use.
There is no integrated debug-method available yet. Have you tried to turn on the debug-mode of WordPress? It allows you to get a log-file of all errors that happens during the execution of a script:
https://wp-staging.com/docs/enable-wordpress-debug-log-mode/
Quote from ray on December 1, 2018, 5:20 amHi
Ok thanks for your comments and clarifications.
I don’t think i have error logging enabled so I’ll check it out.
Hi
Ok thanks for your comments and clarifications.
I don’t think i have error logging enabled so I’ll check it out.
