ban registrations from one email domain

ban registrations from one email domain

Sean S發表於
Number of replies: 29
Is it possible to ban registrations from one email domain. If students register with that domain they would get an error message and an opportunity to use a different email address? If so how would I go about this?

This is important as 50% of my students use hanmail.net (a Korean web mail) that rejects every email that moodle sends them. My inbox is flooded with email bounce notices.
評比平均分數: -
In reply to Sean S

Re: ban registrations from one email domain

Martin Dougiamas發表於
Core developers的相片 Documentation writers的相片 Moodle HQ的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
Sounds like a good candidate for a feature request in the bug tracker ... a new admin configuration could be added.  If you just need to hack then look in login/signup.php at the function validate_form() near the bottom.
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
Martin,

thanks for the tip, but I'm php useless (I know how to do includes and that is it) If you have time, could you provide me with exact instructions. I'm currently running 1.3.4 but will probably upgrade to 1.4 around sept 27 as that is a 5 day holiday in Korea.

Sean
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
Sorry to bump this, but it is really important for me to get this hack implemented if possible. My students cannot seem to comprehend "do not use hanmail.net, if you already registered with hanmail.net change it" Maybe I have the same problem from the Along Comes a Better Idiot thread or it's a language issue or both.

Either way I am in desperate need of a solution.
In reply to Sean S

Re: ban registrations from one email domain

Martin Dougiamas發表於
Core developers的相片 Documentation writers的相片 Moodle HQ的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
Desperate people are welcome at moodle.com/development  微笑 ... otherwise I'm afraid you need to join the queue of people also wanting things done for free...
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
Martin,

I understand. I guess I'm in the queue since I have no knowledge about how to code or the time to learn (currently in graduate school as well as teaching full-time)

Matt, Howard,

I will try that in just a few minutes and get back to you. (I just woke up and need some coffee before I do this) - Hope I don't mess something up really bad!

Thanks for all the suggestions and help everyone.

Sean
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
Martin,

I just realized I do have a few extra dollars in my paypal account and have sent a message to moodle.com/development. Anyhow hopefully it is within budget. I didn't realize that we could pay for features to be added (if they are important enouogh).

Sean
In reply to Sean S

Re: ban registrations from one email domain

Sean S發表於
problem resolved with a few dollars and some excellent work by Martin. Thank-you.

Sean
In reply to Sean S

Re: ban registrations from one email domain

g k發表於
I didn't know we could pay for certain services either.  What was the fee for this service?  I need to block yahoo.com and hotmail.com.
In reply to g k

Re: ban registrations from one email domain

Sean S發表於
g.k.

the total cost was us$150 - which was a little expensive for a poor graduate student, fortunately I have two other graduate student friends who split the cost with me.

According to Martin this feature will be distributed in moodle 1.5 but if you really need it now send me an email eslteacher at gmail.com and I will forward the files to you. If you would like to help up defer the cost you can donate to my paypal account - link on my blog right sidebar - and I will split it with my friends.  If you don't have any spare money, don't worry I'll send you the files regardless.

donation appreciated, but not required.

Sean
In reply to Sean S

Re: ban registrations from one email domain

Sean S發表於
update

This hack will be added to 1.4 cvs later today. One of the other contributers got an email in response to a query that indicated there was an incompatibility with some recent forum changes. Basically Martin is going to fix that and add this to the CVS.

So I guess you really do not need to wait for 1.5 and thus you no longer need to get it from me or even consider donating.

Sean
In reply to Sean S

Re: ban registrations from one email domain

g k發表於
That sounds great. I may end up donating anyway. But I am not sure how to find the updated files.  In other words, which files specifically allow the screening of email domains?  Is it just the user/edit.php file that I have to download and configure?  Is it easy to configure?
In reply to g k

Re: ban registrations from one email domain

Sean S發表於
g.k. send me an email and I will give you the instructions and zip file.

eslteacher at gmail.com
In reply to Sean S

Re: ban registrations from one email domain

g k發表於

Thanks Linguist. I figured it out. Thanks for this request. It was really needed.

In reply to Sean S

Re: ban registrations from one email domain

Martin Dougiamas發表於
Core developers的相片 Documentation writers的相片 Moodle HQ的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
Yes, it's in CVS for 1.4 and DEV versions. For best results, I would recommend updating the whole Moodle to the latest 1.4 version from the download page (or using CVS). Otherwise, the changed files are:

  • config-dist.php (contains information about the config you need to do)
  • lang/en/moodle.php
  • lib/moodlelib.php
  • user/edit.php
  • login/signup.php
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
I can't do CVS - when I upgrade to 1.4 how do I ensure that I have this modification? Download the lastest stable nightly?
In reply to Martin Dougiamas

Re: ban registrations from one email domain

g k發表於
Thank you. Is there a way to donate to the Moodle "research and development fund"?  I don't have much money. But it doesn't seem right to use Moodle for nothing....
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
I just installed a test installation of 1.4 but I cannot find where I ban registrations by email address. I'm sure that I downloaded the latest nightly stable.
In reply to Sean S

Re: ban registrations from one email domain

Martin Dougiamas發表於
Core developers的相片 Documentation writers的相片 Moodle HQ的相片 Particularly helpful Moodlers的相片 Plugin developers的相片 Testers的相片
You have to put one of these config strings in your config.php (for now).  If the first one is set, then Moodle will DISALLOW all domains EXCEPT those listed.  Otherwise, if the second one is set, then all addresses are ALLOWED EXCEPT those listed.

  $CFG->allowemailaddresses = "myschool.edu.au hotmail.com";
  $CFG->denyemailaddresses = "hotmail.com yahoo.com";
In reply to Martin Dougiamas

Re: ban registrations from one email domain

Sean S發表於
Thanks.
In reply to Sean S

Re: ban registrations from one email domain

Sean S發表於
I just thought I would bump this thread to the top and let everyone know that this hack is working exactly as I wanted. I no longer get tons of bounced emails and students recieve notices about class cancellations or changes that are required.

This is definately the best feature in MOODLE, IMHO.

In reply to Sean S

Re: ban registrations from one email domain

Timothy Takemoto發表於

I added a lot of banned email addressses that were
1) common mistakes of the main email domain that students use
2) mobile phone email domains, because they can not cope with the encoding that my moodle is using.
As The Liguist says, this seemed like a great feature.

Then one of my students used one of those banned domains. Then, instead of being able to login he (we) reached a page which said 'instructions for how to login have been sent to you'.

And on the user page, I found that his username required confirmation.

But the strange things is I am using IMAP, so there should be no need for confirmation.

I had imagined that on an IMAP confirmation system, if a student entered a banned email address they would simply be sent to a page where they are told that the email address they have entered is banned.

Is is possible that when a student enters a banned email address moodle assumes that the certification method is by email?

Timothy

In reply to Sean S

Re: ban registrations from one email domain

Howard Miller發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 Plugin developers的相片
This is a clue for a bodge nothing more, nothing less...

in user/edit.php find the line...

if (empty($usernew->email))
$err["email"] = get_string("missingemail");

after this line add something like...

if (!strpos($usernew->email, 'hanmail.net'))
$err["email"] = get_string("missingemail");

I haven't tried it, but the idea is that if the email contains the offending domain name then it will be treated like a missing email. You *could* add a new, more sensible, error message string of course. I don't think that this will work for email registrations, but I haven't got a site with that enabled to see how it works.

Don't shout at me if it all goes horribly wrong 微笑
In reply to Howard Miller

Re: ban registrations from one email domain

Matt (M)發表於

if (!strpos($usernew->email, 'hanmail.net'))
$err["email"] = get_string("missingemail");


Or just really hack it (and possibly make it more informative) to say:

$err["email"] = "We are sorry, @hanmail.net email addresses are not accepted";

??

I ask because I probably may do my fair share of "customizations" and I'm curious as to whether or not the above approach is appropriate (assuming get_string() returns a general string...and my php coding is valid?)?

-Matt
In reply to Howard Miller

Re: ban registrations from one email domain

Sean S發表於
I tried this but it didn't work, the registration still sends the email. THis is exactly what I tried

if (empty($user->email)) {
$err->email = get_string("missingemail");

if (!strpos($usernew->email, 'seans-english.com'))
$err["email"] = get_string("missingemail");


I also tried putting the second if statement before the first (I'll try anything at this point) and when I submitted a registration the email was sent as well.
 
I do really appreciate all the help.
Thank-you

Sean
In reply to Sean S

Re: ban registrations from one email domain

David Scotson發表於
Do you know why the emails are rejected?

If you can figure it out (there may be clues in your bounce messages or you could even just ask someone at hanmail.net) then perhaps that problem may be more common and therefore the hypothetical bug would be a higher priority.

You could also try simply asking hanmail.net to stop bouncing your mail.
In reply to David Scotson

Re: ban registrations from one email domain

Sean S發表於
David,

I asked my wife (Korean) to send an email to hanmail on my behalf. She told me that hanmail even has a bad reputation within Korea for bouncing email. It's so bad that basically all shopping sites do not accept them. 

After we sent the email she told me it was probably a waste of time, but I am hopeful.

Sean