Select Moodle version:

Blocks: QuickmailSMS

A slight modification of quickmail to allow teachers to send text messages to users.
Maintained by: My Hero Paul P.


QuickmailSMS adopts the same license that Moodle does.


Quickmail was developed at Louisiana State University.

QuickmailSMS is a modification of Quickmail by Paul Prencis for sending SMS (text) messages to cellular phones.

Moodle 1.9 had a nice quickmailSMS block.  Unfortunately, it never made its way to moodle 2.x.

Due to the large number of requests from teachers, I modified the quickmail block and created a new quickmailsms block for moodle 2.x

I am submitting it to the plugins database, but while I wait for approval, I am attaching the code for the community to test and provide feed back.

Basically, it works just like the old quickmailsms block:  You create three custom profile fields with the following specifications:

type - checkbox
shortname - opt
name - whatever you feel appropriate
required - yes
display on signup - yes
Who is the field visible to? - visible to user
checked by default - No

type - select
shortname - mobileprovider
name - whatever you feel appropriate
required - no
display on signup - yes
Who is the field visible to? - visible to user
menu options -
Please select one...
Sprint PCS
Virgin Mobile
US Cellular

Default value - Please select one...

type - text
shortname - mobilephone
name - whatever you feel appropriate
required - no
display on signup - yes
Who is the field visible to? - visible to user
Display size - 10
Maximum Length - 10

If you are interested, here was the logic:
Most cellular providers allow text to be sent via their email gateway.  Thus, a text sent to a Verizon customer with cell number (212) 555-1212 will receive a text from an email sent to

I modified the quickmail code to read the cell number and provider information from the mdl_info_data tables and connect them to get the proper text/email address.  The main body of altered code is this (all from email.php around line 265)

        $sucess = '';
        $sms_agree_sql =    'SELECT t1.shortname,
                        FROM {user_info_field} as t1 , {user_info_data} as t2
                        WHERE = t2.fieldid
                        AND t1.shortname = "opt"
                        AND t2.userid = ' . $everyone[$userid]-> id;
        $sms_agree_result = $DB->get_record_sql($sms_agree_sql);
        if($sms_agree_result->data == 1) {
            $sms_number_sql =    'SELECT t1.shortname,
                            FROM {user_info_field} as t1 , {user_info_data} as t2
                            WHERE = t2.fieldid
                            AND t1.shortname = "mobilephone"
                            AND t2.userid = ' . $everyone[$userid]-> id;
            $sms_number_result = $DB->get_record_sql($sms_number_sql);

            $sms_number = $sms_number_result->data;
            $sms_provider_sql =    'SELECT t1.shortname,
                            FROM {user_info_field} as t1 , {user_info_data} as t2
                            WHERE = t2.fieldid
                            AND t1.shortname = "mobileprovider"
                            AND t2.userid = ' . $everyone[$userid]-> id;
            $sms_provider_result = $DB->get_record_sql($sms_provider_sql);
            $sms_provider_full = $sms_provider_result->data;
            $sms_provider_array = explode('~',$sms_provider_full);
            $sms_provider = $sms_provider_array[1];
            $everyone[$userid]->email = $sms_number . $sms_provider;
            $success = email_to_user($everyone[$userid], $user, $subject,
            strip_tags($data->message), $data->message, $zip, $zipname);
        } else {
            $warnings[] = get_string("no_agreement", 'block_quickmailsms', $everyone[$userid]);
        if(!$success) {
            $warnings[] = get_string("no_email", 'block_quickmailsms', $everyone[$userid]);


Some things to do:
1.  Replace the HTML editor with a standard text area.  I tried to do this by editing the formslib call, but there was some other function expecting input and I couldn't get it to work properly.  My workaround was to use the php function 'strip_tags' to remove any html from the form.  Ideas would be greatly appreciated.
2.  Delete all references to code involving attachments, signatures and alternate emails.  As is, they are removed from the forms, but I think leaving the functionality in the code is not a good idea.  Again, ideas would be greatly appreciated.




My Hero
Paul P. (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Picture of Bob Puffer
    Sat, Jun 22, 2013, 11:10 PM
    How does your school come by the information of the student's cellphone provider? If self-entered, how do you validate the field contents? This has always been our hitch with this type of idea so we're looking at utilizing information in our emergency response system, maybe with a magic number that invalidates the need for provider information.
  • My Hero
    Sun, Jun 23, 2013, 8:40 AM
    In our school, the students self-enter the data. There is no way to validate whether the data is correct or not. What teachers who use the block have done at the beginning of the year is to require their students to update their profile with the information and then set up an "assignment" where the students have to get a "secret message" sent in the text and enter it in the assignment text box.

    I'm sure that if your school uses a SIS and does authentication via ldap or some other automated method, the fields could be mapped together.
  • QED
    Wed, Jun 26, 2013, 11:16 PM
    This block has been very popular for us in the past but we just upgraded to 2.4.2 and it looks like the version of this block skipped 2.4. I would love to get this working before this Fall.
  • QED
    Thu, Jun 27, 2013, 12:05 AM
    Ok, I think I just got the 2.3 version working. However on several of the pages when I click continue I get, "The requested URL /blocks/quickmailsms/emailemail.php was not found on this server."
  • QED
    Thu, Jun 27, 2013, 12:12 AM
    I'm talking with myself here. I went into emaillog.php and just changed the link to /blocks/quickmailsms/email.php so it goes to the correct page when you click continue.
  • My Hero
    Thu, Jun 27, 2013, 1:04 AM
    Hi Marc

    You replied to yourself quicker than I could!

    The 2.5 version fixed the broken "continue" link. I haven't updated the 2.3 version yet, but I plan on doing it shortly.

    The 2.3 version should work with 2.4 but I think the 2.5 version should also work with 2.4, but I haven't tried it myself. I'd appreciate if Someone could let me know if the 2.5 version works in 2.4.

    I just saw that the actual "Quickmail" block was just upgraded to 2.4/2.5 so I am going to compare my files with it over the weekend.
  • Picture of Mr. Marc
    Fri, Aug 30, 2013, 5:48 AM
    I'm using Moodle 2.2.1+ (Build: 20120119) do I have any options to be able to use this block?
  • My Hero
    Fri, Aug 30, 2013, 7:04 AM
    hi Marc,

    I haven't tested it on 2.0-2.2, but you can try it out on a test installation to see if it works. if you do try it, use the 2.3 version. Please let us know if it works or not.
Please login to post comments