���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /var/www/dev-kft.petruch.de/classes/mailer.class.php
���ѧ٧ѧ�
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; class Mailer{ private $sql; private $mail; private $host = 'smtp.ionos.de'; private $username = 'noreply@kockzius.com'; private $password = 'yG!E?Z_TiE1e*BO6_87Rh'; private $port = 587; private $secure = 'STARTTLS'; private $from = 'noreply@kockzius.com'; private $fromName = 'Kockzius | Maschinentool'; public function __construct(){ global $sql; $this->sql = $sql; } public function myMail($email,$subject,$html,$attachments=false,$cc=false){ $mailID = $this->logMail($email,$subject,$html,$attachments); $mail = new PHPMailer(true); try { // $mail->Timeout = 10; // $mail->SMTPDebug = PHPMailer\PHPMailer\SMTP::DEBUG_SERVER; $mail->isSMTP(); // Set mailer to use SMTP $mail->Host = $this->host; // Specify main and backup SMTP servers $mail->SMTPAuth = true; // Enable SMTP authentication $mail->Username = $this->username; // SMTP username $mail->Password = $this->password; // SMTP password $mail->SMTPSecure = $this->secure; // Enable TLS encryption, `ssl` also accepted $mail->Port = $this->port; // TCP port to connect to $mail->CharSet = "UTF-8"; $mail->setFrom($this->from, $this->fromName); if(!is_array($email)) $email = [$email]; foreach($email AS $e) $mail->addAddress($e); if ($attachments) { if (is_array($attachments)) { foreach ($attachments as $a) $mail->addAttachment($a); } else $mail->addAttachment($attachments); } $mail->isHTML(true); $mail->Subject = $subject; $mail->Body = $html; $mail->send(); $this->logMailStatus($mailID,1); return true; }catch (Exception $e) { // echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; $this->logMailStatus($mailID,0,1,$mail->ErrorInfo); } return false; } private function logMail($email,$subject,$html,$attachments){ if(!is_array($email)) $email = [$email]; $attachments = ($attachments)?json_encode($attachments):''; return $this->sql->insert('log_mail','fromMail,toMail,subject,message,attachments',[$this->from,implode(',',$email),$subject,$html,$attachments]); } private function logMailStatus($mailID,$success=0,$error=0,$errorMsg=''){ return $this->sql->update('log_mail','success,error,errorMsg',[$success,$error,$errorMsg],'id = ?',$mailID); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�