Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No email is sent when creating a new announcement #7213

Closed
jnugent opened this issue Aug 4, 2021 · 12 comments
Closed

No email is sent when creating a new announcement #7213

jnugent opened this issue Aug 4, 2021 · 12 comments
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us?
Milestone

Comments

@jnugent
Copy link
Member

jnugent commented Aug 4, 2021

Describe the bug
If an announcement is created in OJS 3.3, and the check box for sending an email to all registered users is checked, no email is sent.

This appears to be because the API end point for creating an announcement doesn't do anything with the "sendEmail" form parameter. I've looked through the code and the path seems to be that the add method in PKPAnnouncementHandler validates the request, and if it passes, the AnnouncementDAO creates the new object and adds it via the Service and then returns with a 200 status code. No notification or email is created.

What application are you using?
OJS 3.3.0.7

Additional Information

There's a forum thread: https://forum.pkp.sfu.ca/t/announcement-mass-email-in-not-working-on-ojs-3-3-x/67472

The work around seems to be to use the Bulk Email feature in 3.3 and reposting the contents of the announcement.

@Vitaliy-1
Copy link
Collaborator

Can take Announcement notification next for refactoring, which will fix this.
If I correctly remember such cases with non-editable mails, it was agreed to create an event in the Announcement Repository when an announcement is added and write a listener that sends an email if form data contains send mail option; right, @NateWr?

@Vitaliy-1 Vitaliy-1 self-assigned this Aug 4, 2021
@NateWr
Copy link
Member

NateWr commented Aug 4, 2021

Yes, I think that makes sense. This will be the case whenever the content of the event (announcement title/content) is the same as the body/subject of the email. The same would be true, for example, when a message is sent in a discussion.

@NateWr NateWr added Enhancement:1:Minor A new feature or improvement that can be implemented in less than 3 days. Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. and removed Enhancement:1:Minor A new feature or improvement that can be implemented in less than 3 days. labels Oct 4, 2021
@NateWr NateWr added this to the 3.3.0-9 milestone Nov 23, 2021
@NateWr NateWr added the Try Me This issue might be good for a new contributor. Can you help us? label Nov 23, 2021
@NateWr
Copy link
Member

NateWr commented Nov 23, 2021

The old notification code is here:

https://github.com/pkp/pkp-lib/blob/stable-3_2_1/controllers/grid/announcements/form/AnnouncementForm.inc.php#L188-L203

Introduction of an event could work. But it may be easier in the meantime to reintroduce this to the REST API handler.

@rahmanramsi
Copy link
Contributor

here the pull request @NateWr
#7547
pkp/ojs#3253

NateWr added a commit that referenced this issue Dec 20, 2021
@NateWr
Copy link
Member

NateWr commented Dec 20, 2021

Merged to stable-3_3_0 and ported to main. Thanks for the PR @rahmanramsi! 🎉

@luizbgomide
Copy link
Contributor

I applied the PR #7547 that, but my announcements still aren't being sent via e-mail.

Nothing is reaching the SMTP server. Any ideias?

@NateWr
Copy link
Member

NateWr commented Mar 31, 2022

I just tested this in the stable-3_3_0 branch and it is working for me. When creating an announcement, you need to click the "Send Email" checkbox. Also, users may have opted out of this email in their profile.

This is the code to debug if you want to find out what's happening on your server:

if(filter_var($params['sendEmail'], FILTER_VALIDATE_BOOLEAN)){
import('lib.pkp.classes.notification.managerDelegate.AnnouncementNotificationManager');
$announcementNotificationManager = new AnnouncementNotificationManager(Notification::NOTIFICATION_TYPE_NEW_ANNOUNCEMENT);
$announcementNotificationManager->initialize($announcement);
$notificationSubscriptionSettingsDao = DAORegistry::getDAO('NotificationSubscriptionSettingsDAO'); /** @var NotificationSubscriptionSettingsDAO $notificationSubscriptionSettingsDao */
$userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /** @var UserGroupDAO $userGroupDao */
$allUsers = $userGroupDao->getUsersByContextId($request->getContext()->getId());
while ($user = $allUsers->next()) {
if ($user->getDisabled()) continue;
$blockedEmails = $notificationSubscriptionSettingsDao->getNotificationSubscriptionSettings('blocked_emailed_notification', $user->getId(), $request->getContext()->getId());
if (!in_array(Notification::NOTIFICATION_TYPE_NEW_ANNOUNCEMENT, $blockedEmails)) {
$announcementNotificationManager->notify($user);
}
}
}

@luizbgomide
Copy link
Contributor

@NateWr, does that only work when creating a new Announcement or can I retroactively edit an Announcement and tick the box to send the e-mail (this is what I've done, because I didn't want to spam my users).

If I cannot send an e-mail after the creation, I suggest that this check box be removed from the edit window to avoid confusion.

@NateWr
Copy link
Member

NateWr commented Mar 31, 2022

Yeah it only works when creating an announcement. I'd suggest filing a new issue about the checkbox.

@OhnO395
Copy link

OhnO395 commented Apr 18, 2022

I applied the PR #7547 that have 2 case.

  1. test journal have 3 user can sent via email
  2. The Journal have 990 user aren't being sent via e-mail.

A lot of receiver?

@mdsoft123456
Copy link

hello,
I have the same problem i can't send email from annoncements however all other mail where send. any idea please!!!

@asmecher
Copy link
Member

@mdsoft123456, please take questions like this to our support forum: https://forum.pkp.sfu.ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug:1:Low A bug that does not have a severe consequence or affects a small number of users. Try Me This issue might be good for a new contributor. Can you help us?
Projects
No open projects
Development

No branches or pull requests

8 participants