Showing posts with label moodle. Show all posts
Showing posts with label moodle. Show all posts

Apr 18, 2018

Windows Moodle Email STARTTLS error - fixed!

THE FOLLOWING APPLIES TO AN OLDER VERSION OF MOODLE. YOUR MILEAGE MAY VARY:

The Windows Moodle package is a great, easy way to get Moodle up and running on a Windows machine. The downside? Setting up email is a pain in the rump.  It didn't have to be.

The problem we had was one where the SMTP server would respond with "STARTTLS" errors.  I spent a LOT of time editing my sendmail.ini file (and even installed the latest sendmail for Windows).  Nothing would cure the problem.

I started poking around the Moodle forums, and while they are generally helpful for many things, the STARTTLS error is not one of them.  However, *nix forums ARE helpful.. sorta.

In the Moodle directory on your Windows server, you need to edit the class.phpmailer.php file *in addition* to setting up sendmail as your mailer. Why? Who the heck knows.  In any case, here is what is working for us, so I hope it helps you!

FIRST: MOODLE ADMIN
   Site Administration > Plugins > Message Outputs > EMAIL
   Type your SMTP host, username, password as needed (you NEED the SMTP host, the others may be optional based on YOUR mail handler/mail host. Google requires it)
   Type noreply@yourdomain.com for the no-reply address.  Substitute your REALY domain for the "yourdomain" part there!
SECOND: SENDMAIL
   Download the latest SENDMAIL to your Moodle server and unzip it to X:\moodle\server\sendmail (substitute the actual driver letter for X there!)
   On your server, go to your X:\moodle\server\sendmail folder
   EDIT the sendmail.ini file:
       smtp_port=25 (usually leave this as is)
       smtp_ssl=auto (could specify TLS here)
       auth_username=valid.user@yourdomain.com
       auth_password=ValidUsersPa$$word
       hostname=yourdomain.com
THIRD: PHPMAILER
   Navigate to X:\moodle\server\moodle\lib\phpmailer on your server (again, substitue your actual location for X)
   EDIT the class.phpmailer.php file (use WordPad)
   SEARCH for TLS
   A few lines down, edit the "SMTPSecure" line:
       public $SMTPSecure = 'tls';
   DO NOT CHANGE ANYTHING ELSE IN THIS FILE!!
FOURTH: PHP.INI
   Navigate to X:\moodle\server\php
   EDIT the php.ini file:
       SMTP = yourmailserver.com
       smtp_port = 25
       sendmail_from = valid.user@yourdomain.com
       sendmail_path = "X:\moodle\server\sendmail\sendmail.exe -t"
   SAVE the file.
Once you have done these, you need to STOP MOODLE then START MOODLE in order for the system to take the changes.
Moodle email may not run by itself.  You can use Task Scheduler in order to call the CRON.PHP page in your Moodle environment. Or you can use MoodleCron for Windows. Very easy to use!
NOTE: Use at your own risk. This worked for me. I hope it works for you, but I will not be held liable for anything that goes wrong with your server/environment/etc.
NOTE: The above steps may be a bit of overkill.  Some steps may not be required in order to get email working in Moodle. I have not gone back to determine just which step(s) worked.  Once it was fixed, I didn't break it again.

Feb 7, 2014

Work Life: Moodling Around in Windows

We have a couple Moodle servers running at our facilities. One of those runs on an older Server 2003 box and is running v2.1.2 of Moodle. Since Moodle is now up to 2.6.1 (at the time of this post), I thought it would be a good idea to get the Windows install up to date.

The first thing I had to do was stop Apache, MySQL, and PHP. Easy enough, usually. But, in this case, mysqld.exe would not quit. I finally had to force it down.

The next thing I did was to delete a couple large log files:
  • In the apache\logs\ folder, delete "error.log" (mine was 90GB!!)
  • In the mysql\data\ folder, delete "mysql_error.log" (mine was 1.5GB)
At that point, I copied my "Moodle" folder to another location.

Once that was done, I started MySql again and fired up the trial version of "Navicat" in order to do a MySql backup. Though, I believe this is an unnecessary step since everything in my Moodle installation falls under one "moodle" folder. Better safe than sorry.

Because I was running 2.1.2, I had to upgrade to 2.2.11 before moving to 2.6.1.

I deleted everything in my "moodle\server\moodle" folder EXCEPT for a folder I had created to store some external files and the config.php file.

I started Moodle (apache, mysql, php) again and went into admin mode to upgrade. NOTE: I found instructions online that said to copy the blocks, mod, and theme folders from your old install to the new one. That did NOT work for me. When I tried that, my install never would give me the "Upgrade" option.

Well, in case anyone else runs into this, here is what I did:

Added the following lines to the end of my moodle\config.php:
ini_set ('display_errors', 'on');
ini_set ('log_errors', 'on');
ini_set ('display_startup_errors', 'on');
ini_set ('error_reporting', E_ALL);

That gave me an error about a moodle\search folder not existing. Sure enough. That folder was in 2.1 but not the 2.2 distro. I copied it out of my 2.1 and at least got through things.

I notice it is also not in the 2.6 distro, so I assumed I would have the same problem. I ventured forth anyway. I copied my now-upgraded 2.2.11 folder out and replaced it with the 2.6 folder from the download. I then put back my config.php and any folders I had specifically created at the file level.

Once that was done, I fired up the XAMPP and went to my site for set-up.

Everything seems okay, though 2.6 is WWAAAAYYY slower than previous versions. There are a few lines of code that can be used in php to help this, supposedly, so I will give that a shot.