<?php
require __DIR__ . '/includes/globalinclude.php';
$Einstellungen = \Shop::getSettings ( [
CONF_EMAILS
] );
$mail = new \stdClass();
$mail->toEmail = $Einstellungen['emails']['email_master_absender'];
$mail->fromEmail = $Einstellungen['emails']['email_master_absender'];
$mail->fromName = $Einstellungen['emails']['email_master_absender_name'];
$mail->replyToEmail = $Einstellungen['emails']['email_master_absender'];
$mail->replyToName = $Einstellungen['emails']['email_master_absender_name'];
$mail->subject = "mein testbetreff";
$mail->bodyText = "mein test Text";
$mail->bodyHtml = "mein Test HTML Text";
$mail->lang = "utf-8";
$mail->methode = $Einstellungen['emails']['email_methode'];
$mail->smtp_hostname = "dateispeicher.de";
$mail->smtp_port = $Einstellungen['emails']['email_smtp_port'];
$mail->smtp_auth = $Einstellungen['emails']['email_smtp_auth'];
$mail->smtp_user = $Einstellungen['emails']['email_smtp_user'];
$mail->smtp_pass = $Einstellungen['emails']['email_smtp_pass'];
$mail->SMTPSecure = $Einstellungen['emails']['email_smtp_verschluesselung'];
function verschickeMeineMail($mail)
{
$mail->cFehler = '';
$bSent = false;
if (!$mail->methode) {
SendNiceMailReply($mail->fromName, $mail->fromEmail, $mail->fromEmail, $mail->toEmail, $mail->subject, $mail->bodyText, $mail->bodyHtml);
} else {
//phpmailer
$phpmailer = new PHPMailer();
$lang = ($mail->lang === 'DE' || $mail->lang === 'ger') ? 'de' : 'end';
$phpmailer->SetLanguage($lang, PFAD_ROOT . PFAD_PHPMAILER . 'language/');
$phpmailer->Timeout = SOCKET_TIMEOUT;
$phpmailer->From = $mail->fromEmail;
$phpmailer->Sender = $mail->fromEmail;
$phpmailer->FromName = $mail->fromName;
$phpmailer->AddAddress($mail->toEmail, (!empty($mail->toName) ? $mail->toName : ''));
$phpmailer->AddReplyTo($mail->replyToEmail, $mail->replyToName);
$phpmailer->Subject = $mail->subject;
switch ($mail->methode) {
case 'smtp':
$phpmailer->IsSMTP();
$phpmailer->SMTPDebug = 4;
$phpmailer->Host = $mail->smtp_hostname;
$phpmailer->Port = $mail->smtp_port;
$phpmailer->SMTPKeepAlive = true;
$phpmailer->SMTPAuth = $mail->smtp_auth;
$phpmailer->Username = $mail->smtp_user;
$phpmailer->Password = $mail->smtp_pass;
$phpmailer->SMTPSecure = $mail->SMTPSecure;
break;
}
if ($mail->bodyHtml) {
$phpmailer->IsHTML(true);
$phpmailer->Body = $mail->bodyHtml;
$phpmailer->AltBody = $mail->bodyText;
} else {
$phpmailer->IsHTML(false);
$phpmailer->Body = $mail->bodyText;
}
$bSent = $phpmailer->Send();
$mail->cFehler = $phpmailer->ErrorInfo;
}
// Emailhistory
if ($bSent) {
$oEmailhistory = new Emailhistory();
$oEmailhistory->setEmailvorlage($kEmailvorlage)
->setSubject($mail->subject)
->setFromName($mail->fromName)
->setFromEmail($mail->fromEmail)
->setToName((isset($mail->toName) ? $mail->toName : ''))
->setToEmail($mail->toEmail)
->setSent('now()')
->save();
} else {
Jtllog::writeLog('Email konnte nicht versendet werden! Fehler: ' . $mail->cFehler, JTLLOG_LEVEL_ERROR, false, 'kEmailvorlage');
}
}
echo "<pre>";
verschickeMeineMail($mail);
echo "</pre>";
echo "fertig";