Problem sending bulk emails (koa)

Hi I am trying to set the instructor send mass emails to students (koa.master). I have enabled the feature from django Enabling the Bulk Email Feature — Open edX Release Notes documentation and I see the option in the instructor area.
My mail servers are configured ok in the lms.yml and studio.yml because users receive emails during registration.
However when the instructor tries to send the email to the students, I get the error “message failed to be emailed to 4 recipients” on the email task progress of the instructor. However, the task state is sucess. The task status is “not completed” Any ideas what am I missing?

Hello,

You have already reviewed the logs that the platform sends you when it sends the mail, since these versions have a problem when the mail concatenates the course id to the mail, generating authentication problems if you use normal accounts such as gmail or outlook.

Hi, and thanks.
I am not sure I understand your response. I am trying to bulk email (mass email) the users in the course. Currently there are only 4 users in the course and none of them have gmail. No email is sent (0 out of 4), so this is not just the problem with specific email addresses.

I found this in the lms.log

smtplib.SMTPRecipientsRefused: {‘giannop@sch.gr’: (550, b’5.1.0 CS102-netin-noreply@sch.gr: Sender address rejected: User unknown in relay recipient table’)}

The FROM email does not match the real email account FROM address. edx adds a CS102 in front of it and this is rejected by the mail server. Can you please let me know how to fix this in edx?

Hi, I found the problem in the logs: smtplib.SMTPRecipientsRefused: {‘gianok@sh.gr’: (550, b’5.1.0 CS102-etn-noreply@sh.gr: Sender address rejected: User unknown in relay recipient table’)}
It seems that CS102- is automatically added in front of the email address in the FROM, and my mail server rejects this sender. Can you please let me know how to fix this, so that the course ID is not automatically added to the FROM email address?
I tried to add the parameter EMAIL_USE_COURSE_ID_FROM_FOR_BULK: false in the lms.yml but no luck

Well then I guess this a duplicate of Bulk emails sending too fast causing gmail to block account. Is there a way to rate limit?
I have opened a PR a while ago, to resolve this at: fix: make bulk_email send email task handles a retryable exception by ghassanmas · Pull Request #29080 · openedx/edx-platform · GitHub

However if your sender account is Gmail and you are using plain email/password to authticate you would need to make sure Less secure apps & your Google Account - Google Account Help.
The refrenced duplicate would apply you, when if it succeed for some emails and failed for others.

While I might have this problem later on when I try to send mass emails, the current problem is the FROM address, which is different than that of the actual email user that tries to send the email (configured in lms.yml). My mail server (not gmail) does not allow this. The FROM and the actual email user must match.

I tried another mail server that allows this and it works. So the problem is that EDX automatically adds the course prefix to the FROM email address.

I have added the EMAIL_USE_COURSE_ID_FROM_FOR_BULK flag in the lms.yml, but it does not seem to work, unless I am adding it in the wrong section inside the file.

From the manual:
“bulk_email.EMAIL_USE_COURSE_ID_FROM_FOR_BULK
If False, use the same BULK_EMAIL_DEFAULT_FROM_EMAIL or DEFAULT_FROM_EMAIL as the from_addr for all bulk email, to avoid issues with spam filtering”

Yeah you are right, its not related I think I came to my conculusion too quickly.
So regarding the EMAIL_USE_COURSE_ID_FROM_FOR_BULK can you check from the settings that its false. have you tried to restart the lms after applying the new settings.

There was no EMAIL_USE_COURSE_ID_FROM_FOR_BULK line existed in the studio and lms YML files at all. I added it under the features as a test, and then in another test outside the features section of the files. And I set it to false. But problem is not corrected.

What version are you running? I think simlair issue has been resolved here Bulk course emails are rejected by email server because of an invalid "from" address · Issue #102 · openedx/build-test-release-wg · GitHub

So if you are running an older version piror to the fix patch (which is applied from maple I guess).
You might need to set EMAIL_USE_DEFAULT_FROM_FOR_BULK to True

I am using koa.master native install
No, this flag did not work for me. add into lms.yml EMAIL_USE_DEFAULT_FROM_FOR_BULK: true
smtplib.SMTPRecipientsRefused: {‘giapk@sh.gr’: (550, b’5.1.0 CS102-ein-noreply@sh.gr: Sender address rejected: User unknown in relay recipient table’)}
Of course I restart the services.

Just make sure you apply EMAIL_USE_DEFAULT_FROM_FOR_BULK for the settings not the config… It can be quite confusing somtimes, since featuers changes are applied to the config which set in the yml file, but for setting its applied to the common or productions files in the settings directory

Which settings you mean please? Inside the studio or django somewhere or is there a settings directory?
Thanks for all the help BTW!

1 Like

In either edx-platform/lms/envs/common.py or edx-platform/lms/envs/production.py

Ok, I added:
EMAIL_USE_DEFAULT_FROM_FOR_BULK = True

In /edx/app/edxapp/edx-platform/lms/envs/common.py
and in /edx/app/edxapp/edx-platform/lms/envs/production.py

I restarted the lms/cms/edxapp_worker

but it did not work :frowning:

hmmm I had to do the next in koa.master in order to suceed:

go to:
/edx/app/edxapp/edx-platform/lms/djangoapps/bulk_email/tasks.py
and change the line in function:
_get_source_address
from
email=u'<{course_name}-{from_email}>',
to
email=u'<{from_email}>',

And then restart the services.

I do not like I had to change the source code, but this is the only thing worked…

1 Like

To correct this, I did the following:

https://blahblah.mx/correct-errors-in-bulk-mail/

That link cannot load (Page not found)

I found the correct link. It is https://blahblah.mx/corregir-errores-en-bulk-mail/
Use google translate to translate it.
Basically it is a similar procedure (note he uses ironwood not koa). But he edits another part of the code and he compiles the file with python -m compileall task.py to create the task.pyc file.

I have not compiled anything in koa and it still works. Note that /edx/app/edxapp/edx-platform/lms/djangoapps/bulk_email/ in koa does not contain any .pyc files!

1 Like