extend sample config and allow setting encryption

This commit is contained in:
2019-01-24 01:32:16 +01:00
parent 2e02fca7c3
commit c60a1bb2ac
2 changed files with 17 additions and 3 deletions

View File

@@ -5,6 +5,18 @@ $config = [
// Which e-mail-adresse shall the bot use to send e-mails?
"register_email" => 'register_bot@example.com',
// which settings should be used to send via SMTP Gateway?
"smtp" => [
"host" => "localhost",
"port" => "25",
// use authentication?
"user" => "register@example.com",
"password" => "SecretEMailPassword",
// Use some encryption to SMTP-Server? [ssl, tls] or unset
"encryption" => False
],
// Where should the bot post registration requests to?
"register_room" => '$registerRoomID:example.com',

View File

@@ -35,14 +35,16 @@ function send_mail($receiver, $subject, $body) {
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = $smtp_conf["host"]; // Specify main and backup SMTP servers
$mail->Port = $smtp_conf["port"]; // TCP port to connect to
if (isset($smtp_conf["user"])) {
if (!empty($smtp_conf["user"])) {
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $smtp_conf["user"]; // SMTP username
if (isset($smtp_conf["password"])) {
if (!empty($smtp_conf["password"])) {
$mail->Password = $smtp_conf["password"]; // SMTP password
}
}
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
if (!empty($smtp_conf["encryption"])) {
$mail->SMTPSecure = $smtp_conf["encryption"]; // Enable TLS encryption, `ssl` also accepted
}
} else {
// fallback to sendmail functionality (as before)
$mail->isSendmail();