私の場合、下記手順によりテストメールを送信できました。
テスト環境:
Moodle 3.6.2+ (Build: 20190222)
CentOS Linux release 7.6.1810
PHP 7.1.26
MariaDB 10.1.38
1. Firewalld (iptables) を停止する。
2. Moodleのプログラムを修正する。
修正対象プログラム:
lib/phpmailer/moodle_phpmailer.php
修正箇所:
138行目
[ 修正前 ]
$mail = new stdClass();
$mail->header = $this->MIMEHeader;
$mail->body = $this->MIMEBody;
$mail->subject = $this->Subject;
$mail->from = $this->From;
$mail->to = $this->to[0][0];
phpunit_util::phpmailer_sent($mail);
return true;
} else {
return parent::postSend();
}
[ 修正後 ]
$mail = new stdClass();
$mail->header = $this->MIMEHeader;
$mail->body = $this->MIMEBody;
$mail->subject = $this->Subject;
$mail->from = $this->From;
$mail->to = $this->to[0][0];
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
phpunit_util::phpmailer_sent($mail);
return true;
} else {
return parent::postSend();
}
3. Moodleの「管理 > サイト管理 > サーバ > メール > 送信メール設定」を変更する。
SMTPホスト smtphosts:
smtp.gmail.com:465
SMTPセキュリティ smtpsecure:
SSL
SMTP認証タイプ smtpauthtype:
NTLM
SMTPユーザ名 smtpuser:
Gmailアカウント名@gmail.com
SMTPパスワード smtppass:
Gmailパスワード
SMTPセッション制限 smtpmaxbulk:
1
4. メール クライアントにログインできるようにするため下記Googleページにアクセスする。
https://www.google.com/accounts/DisplayUnlockCaptcha
5. 「管理 > サイト管理 > サーバ > メール > eMail Test」でテストメールを送信する。
[Moodle plugins directory: Moodle eMail Test]
https://moodle.org/plugins/local_mailtest