diff --git a/config.sample.php b/config.sample.php index d6c0842..aad37f9 100644 --- a/config.sample.php +++ b/config.sample.php @@ -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', diff --git a/mail_templates.php b/mail_templates.php index ec023ce..ab22402 100644 --- a/mail_templates.php +++ b/mail_templates.php @@ -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();