Files
sternwarte_server/html/sternwarte/phpmailer/dosendmail.php_copy
2025-11-02 22:52:08 +01:00

59 lines
1.2 KiB
Plaintext

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
function sendmail($subject, $from, $body, $cc=[], $bcc=[], $to=[]) {
global $develop;
$ret = [];
$ret['error'] = false;
$mail = new PHPMailer();
$mail->CharSet = 'utf-8';
$mail->isSMTP();
if ($develop == 'true') {
$mail->Host = 'mailhog';
$mail->Port = 1025;
} else {
$mail->SMTPAuth = true;
$mail->Host = "sslout.df.eu";
$mail->Port = "465";
$mail->SMTPSecure = "ssl";
$mail->Username = "sonderfuehrung@sternwarte-welzheim.de";
$mail->Password = "v|kR9D8m}K";
}
$mail->setFrom($from);
if (count($to) != 0) {
foreach ($to as $t) {
$mail->addAddress($t);
}
}
$mail->Subject = $subject;
$mail->Body = $body;
if (count($cc) != 0) {
foreach ($cc as $c) {
$mail->addCC($c);
}
}
if(count($bcc) != 0) {
foreach ($bcc as $bc) {
$mail->addBCC($bc);
}
}
$mail->addReplyTo($from);
if (!$mail->send()) {
$ret['error'] = true;
$ret['errortext'] = $mail->ErrorInfo;
}
return $ret;
}
?>