Contact Form

General plugins (Local) ::: local_contact
Maintained by Picture of Michael MiletteMichael Milette
Contact Form is a Moodle plugin that allows your site to process and send information submitted through HTML web forms to the site's support email address or primary administrator if the support email address is not defined.
Latest release:
2896 sites
1k downloads
52 fans
Current versions available: 1

The Contact Form plugin for Moodle processes information submitted through a custom web form, sending it by email to the site's support email address, if defined, or to the primary system administrator.

Examples uses for this plugin include:

  • Contact us form.
  • Support request form.
  • Request a course form.
  • Information request form.
  • Lead generation form.
  • Membership application form.
Share with us how you use this plugin on your site.

Note: This is not a web form builder but a form processor. You must have some knowledge of how to create HTML forms or at the very least be able to cut and paste the example included in the README file. If you are not familiar with HTML, consider using the {form...} tags included with the FilterCodes plugin. You are just one plain text tag closer to having a common webform than you think.

The initial work for this project was sponsored by the kind folk at l'Action ontarienne contre la violence aux femmes. Contact Form benefits from ongoing development by TNG Consulting Inc..

Potential privacy issues

Reminder: Email message protocols may cross the Internet and store messages on mail servers in unencrypted plain text. If you are sending messages outside of your local area network, it is highly recommended that you do not use this plugin to collect sensitive information such as social insurance or credit card numbers. It has nothing to do with this plugin's functionality but just with the way email protocols work. This plugin on its own does not store any information - anywhere.

Screenshots

Screenshot #0
Screenshot #1
Screenshot #2

Contributors

Picture of Michael Milette
Michael Milette (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Comments

  • Picture of Michael Milette
    Mon, Sep 21, 2020, 3:55 AM
    Hi Ekkaggata Technologies. It is indeed compatible with Moodle 3.9 and will be indicated as such shortly. I am not sure what text box field you are expecting to see. This is a form processor, not a form builder. Please read the documentation on how to create a form and then ask any questions you might have in the discussion forum. Links to both of these are included in the Useful Links section of the Contact Form plugin page.

    Best regards,

    Michael
  • Picture of cyber sec
    Sun, Jan 10, 2021, 5:17 AM
    Cannot get this work again, and I cannot understand why. Any help trouble-shooting would be appreciated.
    My webhost crashed my site. They had some huge hardware issue. Fortunately, I saved my content, including my contactus.html file, and my sendmail.php file.
    I am using Moodle 3.7.7. That is the most recent version my hosting company allows. I am not using SSL or TLS for my email.
    I put the contactus.html in a static page, and the sendmail.php in the ../public_html/local/contact/ directory. This is the same way I had setup before.
    I set up outgoing email in moodle, and tested it, it works fine.
    But the contact form will not send emails. I am not sure how to trouble-shoot this.
    I stripped down the contactus.html form because I kept getting sesskey errors. This was working fine:
    -------------
     <form action="../../local/contact/sendmail.php" method="post">
    <label for="email" id="emaillabel">Email address <strong class="required">(required)</strong></label><br>
    <input id="email" name="email" type="email" size="57" maxlength="60" required="required" value=""><br><br>
    <label for="subject" id="subjectlabel">Subject <strong class="required">(required)</strong></label><br>
    <input id="subject" name="subject" type="text" size="57" maxlength="80" minlength="5"
    title="Minimum 5 characters." required="required"><br><br>
    <label for="message" id="messagelabel">Message <strong class="required">(required)</strong></label><br>
    <textarea id="message" name="message" rows="5" cols="58" minlength="5"
    title="Minimum 5 characters." required="required"></textarea><br>
    <input value="Submit" type="submit">
    </form>

    ---------------
    Here is the sendmail.php
    -----------------
    <?php
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    $message=$_POST['message'];
    mail($email ,$subject, $message);
    ?>
  • Picture of Michael Milette
    Sun, Jan 10, 2021, 7:00 AM
    Hi cyber sec, I'm not sure what any of what you posted has to do with the contact plugin. If you are trying to create your own code, I would suggest asking your question in the Moodle General Developer forum.
  • Picture of cyber sec
    Mon, Jan 11, 2021, 7:48 AM
    I have the contact form plugin installed. The index.php file, and so on, are in the ../public_html/local/contact/ directory. I stripped down the code, a little, in those particular files, because I kept getting a sesskey error.
    But, as you can see, there is nothing wrong with the html code, or php code. I have tried these outside of moodle, and they work.
  • Picture of Michael Milette
    Tue, Jan 12, 2021, 1:14 AM
    Hi cyber sec. I can only try to help you here if you use the FilterCodes plugin as it was designed to be used. In order to help you with your sesskey error, see https://github.com/michael-milette/moodle-local_contact/blob/master/README.md#sesskey-error

    If you are committed to making your code work, I suggest you ask your question in the developers forum. I will give you a hint though - you've stripped out too much code when making your sendmail.php.
  • Picture of Blair F.
    Wed, Jan 13, 2021, 3:21 AM
    I know I'm probably just blind, but I cannot figure out how to get the 'reply to' address to be that of the person filling in the form. I can see how to make it Moodle's noreply address, or to override that to something else for all messages, but not how to make it dynamic and show the user. I thought maybe putting the filtercode {email} into the 'custom sender' field would help, but it just defaulted to the noreply address.
  • Picture of Michael Milette
    Wed, Jan 13, 2021, 10:09 AM
    Hi Blair, the reply to address is automatically populated with the senders email address. However you cannot see this unless you view the SMTP header. Another way to see it is to simply click reply to an email you receive. You will then notice that the return address is not the same as the From field. The reason for this is that most SMTP (i.e. email) servers do not allow emails to be sent from an email address that it does not recognize. This actually makes sense when you think about it because it is your website sending the email and not really the user. Anyway, this is why there is a from address and a reply-to address. If you want to discuss the further, please start a discussion on the discussion forum at https://moodle.org/mod/forum/discuss.php?d=352851 . If you think you have a valid valid case for a dynamic "from" field, please submit your feature request at https://github.com/michael-milette/moodle-local_contact/issues/ . I don't think it would be much work to develop a solution but I would want to make sure that it is going to actually work for you before I invest my time. Like I said, most mail servers would reject this.

    Best regards,

    Michael
  • Picture of Blair F.
    Thu, Jan 14, 2021, 5:55 AM
    Ah, OK. Thank you for that very good explanation. Our messages go from the contact form to our support email address and are then picked up by our HelpDesk software (TeamDynamix). The tickets being created in TeamDynamix are using the FROM and not the REPLY TO to determine the ticket initiator. I will look at this further to see if I can figure out if there's anything I can do and then follow your suggests of posting in the forum and possibly a feature request. Thank you again. You are very responsive, and that's greatly appreciated.
  • Picture of cyber sec
    Fri, Jan 15, 2021, 4:03 AM
    Okay, I figured out what I left out in sendmail.php. Not sure why I saved the file like that, but it was obvious when I took a look. Seems to be working now. Thank you.
  • Picture of Michael Milette
    Sat, Jan 16, 2021, 2:40 AM
    You are very welcome Blair and cyber sec. Have a great weekend!
  • Picture of cyber sec
    Sun, Feb 14, 2021, 5:21 AM
    Gmail works as an outbound mail server in Moodle, but not with this plugin.

    I have created a mydomain@gmail.com account to use for outbound email on Moodle. This works on Moodle, I have ran the outbound mail test, and I have tested student self registration. I have done these tests multiple times, it always works.

    But it does not work when using this plugin. I have put echo statements in sendmail.php to make sure that sendmail.php is being called correctly, and that all the information is correct. But the message is never sent to the mydomain@gmail.com account.
    <?php
    $email=$_POST['email'];
    echo "email $email";
    $subject=$_POST['subject'];
    echo "subject $subject";
    $message=$_POST['message'];
    echo "message $message";
    mail("mydomain@gmail.com", $email ,$subject, $message);
    ?>
  • Picture of Michael Milette
    Sun, Feb 14, 2021, 6:11 AM
    If you want help, please move this discussion to the discussion forum. https://moodle.org/mod/forum/discuss.php?d=352851
  • Picture of R A
    Fri, Apr 2, 2021, 5:34 AM
    Hi,
    After installing this plugin to our Moodle version 3.0+ using PHP 5.4, I am not able to go back to site administration. I got the following error

    JSON.parse: unexpected end of data at line 1 column 1 of the JSON data

    Is there a way to resolve this? The clients do not want to upgrade their Moodle version.

    Thank you
  • Picture of Michael Milette
    Sun, Apr 4, 2021, 10:16 PM
    Hi RA, I am not sure why Contact Form would cause this problem as it does not use json. However I have seen this problem when running older versions of Moodle on Windows but it is unrelated to the plugin. If you think it is related, you could simply delete the /local/contact directory.
  • Picture of R A
    Thu, Apr 15, 2021, 12:54 AM
    Thank you, Michael. I think it's the php version that we used (5.4). I ended up deleted the plugin from the server and everything worked.
Please login to post comments