Can I set the priority of news sent by SMF? newsletter create delay...

Started by luuuciano, October 03, 2014, 05:03:33 PM

Previous topic - Next topic

luuuciano

Yesterday I was sending a news, to all the members... using 300 emails by hour... that was like having the forum sending news emails 12hs...
I have noticed that regular notifications were not sended in time, after the news long queue finishid all the members received the 12hs notifications at the same time...

I was looking the function ReduceMailQueue in ScheduledTasks.php, it has:

// Now we know how many we're sending, let's send them.
$request = $smcFunc['db_query']('', '
SELECT /*!40001 SQL_NO_CACHE */ id_mail, recipient, body, subject, headers, send_html, time_sent, private
FROM {db_prefix}mail_queue
ORDER BY priority ASC, id_mail ASC
LIMIT ' . $number,
array(
)
);


So... the queue is in fact ordered/sent by priority... right?

It would be nice if I can set a lower priority to the newsletters, so all the regular notifications (created by member interaction in "real time") are sent in time (like being merged in the newsletter long queue)... not a lot of time after it happens...

And we have nearly 3k members, that will be worse in larger forums...
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

Kindred

Newsletters are, by default, set to a HIGHER a priority than normal notifications, I  believe...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

luuuciano

Quote from: Kindred on October 03, 2014, 06:39:55 PM
Newsletters are, by default, set to a HIGHER a priority than normal notifications, I  believe...

Uhhmmmmm, do you know where to change to have the opossite?

BTW, a way to select priority in newsletters / regular notifications would be nice... DEFCON 5 or DEFCON 1 (?)
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

DSystem

Digging up this topic. I'm having the same problem.

I needed to figure out some way to change the priority of sending a newsletter.

margarett

Never used this myself, but I think this should be easy enough:

ManageNews.php, find the 2 lines that start with "sendmail("
sendmail($email, str_replace($from_member, $to_member, $_POST['subject']), str_replace($from_member, $to_member, $_POST['message']), null, null, !empty($_POST['send_html']), 5);
And
sendmail($row['email_address'], $subject, $message, null, null, !empty($_POST['send_html']), 5);
See the "5" in the end? That's the priority, play with it ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

luuuciano

But... that is the "email priority" atribute? nothing to do with smf sending newsletter/queue functions?
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

margarett

Well it's supposed to be the same thing. The email priority determines how the queue deals with them. But IIRC the "5" is actually the lowest of all priorities...
You can see the mails in the queue, the one coming from Newsletters should have "Very Low"...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

DSystem

@margarett, Thank you very much for showing the way.

Sendmail priorities from 0 to 5:
5 = Very Low
4 = Low
3 = Normal
2 = High
0,1 = Very High

To better understand how this organized the priorities of email at SMF. I researched all the scripts that use the sendmail function:

Script => priorities
/sources/Post.php => 5,3
/sources/Subs-Auth.php => 0
/sources/ScheduledTasks.php => 2,4
/sources/Subs-Db-mysql.php => 0
/sources/Profile-Modify.php => 0,2
/sources/Register.php => 0
/sources/Subs-Members.php => 0
/sources/ManageNews.php => 5
/sources/Reminder.php => 0
/sources/Subs-Admin.php => 1
/sources/Groups.php => 2
/sources/ManageMembers.php => 0,1
/sources/SendTopic.php => 0,2

For sending the list of emails doesn't get in the way of notifications of Forum changed the priority of sendmail in posts.php of 5 to 4

I believe this should be the default setting of SMF

More information on sendmail function at this link -> http://support.simplemachines.org/function_db/index.php?action=view_function;id=314

Kindred

Interesting... So it is the opposite of what I had originally thought...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

luuuciano

Nice findings DSystem!

After reading it I have tried using 4 in post (4,3),,,,,

Then sent a newsletter... and now I have received a notification of a post reply made 8 hours before... :(
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

DSystem


margarett

@luuuciano: the priority of a mail already in the queue isn't changed anymore. So that notification arrived when it had to arrive.
In order to see the results of the change, you need to send a newsletter (and have lots of mails in the queue with very low priority), then get a notification of a topic (eg, reply to it with a different user).
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

luuuciano

But... I did the change, and all those newsletter emails should have the lowest 5 priority (I did it after the changes), and the post reply a 4 priority? so, I expected to receive that notification "in time", not after all the news were sent...

If that do not work, when you have a forum with 50000 members you will have to sit and wait 100 hours to start receiving regular notifications? (a big bunch of notifications btw, lol)

Will check the queue on the next newsletter, did not this time....
No me agradan los foros que no te dejan borrar TU PROPIO usuario, como por ejemplo smfsimple.com.
E incluso te mandan emails no solicitados, de los cuales, quizá, no puedas escapar porque NO te dejan posibilidad a deshabilitarlos (a menos que NO te tengan en su lista negra).

margarett

The idea is that more prioritary emails arrive before the others, I'm just not sure of the "immediateness" ;D
Just on a priority 0 the mail is sent immediately. The others have some "weight" to respect. TBH I never looked at that code :P
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

DSystem

So today I went to send a mailing list and test my amendment that did not work. :(

I found that all the emails from the queue for the mailing list are priority (2)

And that any priority that put in sendmail (manageNews.php), has no effect. The e-mail is always registered in smf_mail_queue with priority 2

As a temporary solution I ran this command in the database.

Update ' smf_mail_queue ' SET ' priority ' = 5 WHERE ' priority ' = 2

Whenever I send a email list click on "Send to these groups using personal message.". I believe the problem is related to this.

DSystem

Resolved and tested.

Following the updates that did:

Sub-Post.php

From
function sendpm($recipients, $subject, $message, $store_outbox = false, $from = null, $pm_head = 0)

To
function sendpm($recipients, $subject, $message, $store_outbox = false, $from = null, $pm_head = 0, $priority = 2)

From
sendmail($notification_list, $mailsubject, $mailmessage, null, 'p' . $id_pm, false, 2, null, true);

To
sendmail($notification_list, $mailsubject, $mailmessage, null, 'p' . $id_pm, false, $priority, null, true);

ManageNews.php
From
sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message);

To
sendpm(array('to' => array($row['id_member']), 'bcc' => array()), $subject, $message, false, null, 0, 5);

Post.php
From
sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, null, false, 5);

To
sendmail($mail['recipients'], $mail['subject'], $mail['body'], null, null, false, 4);

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Steve

DO NOT pm me for support!

Advertisement: