/
Slav468
/
test
Обзор
Документация
Войти
/
Slav468
/
test
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/components/sendmail/sendmail.php
65 строк
2 KB
Slav468
feat: init commit
15 июл 2024, 14:31
15 июл 2024, 14:31
0fdfc9b
Код
Авторство
О чём код?
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'phpmailer/src/Exception.php'; require 'phpmailer/src/PHPMailer.php'; require 'phpmailer/src/SMTP.php'; $mail = new PHPMailer(true); $mail->CharSet = 'UTF-8'; $mail->setLanguage('ru', 'phpmailer/language/'); $mail->IsHTML(true); /* $mail->isSMTP(); //Send using SMTP $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'user@example.com'; //SMTP username $mail->Password = 'secret'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = 465; */ //Від кого лист $mail->setFrom('from@gmail.com', 'Фрілансер по життю'); // Вказати потрібний E-mail //Кому відправити $mail->addAddress('to@gmail.com'); // Вказати потрібний E-mail //Тема листа $mail->Subject = 'Вітання! Це "Фрілансер по життю"'; //Тіло листа $body = '<h1>Зустрічайте супер листа!</h1>'; //if(trim(!empty($_POST['email']))){ //$body.=$_POST['email']; //} /* //Прикріпити файл if (!empty($_FILES['image']['tmp_name'])) { //шлях завантаження файлу $filePath = __DIR__ . "/files/sendmail/attachments/" . $_FILES['image']['name']; //грузимо файл if (copy($_FILES['image']['tmp_name'], $filePath)){ $fileAttach = $filePath; $body.='<p><strong>Фото у додатку</strong>'; $mail->addAttachment($fileAttach); } } */ $mail->Body = $body; //Відправляємо if (!$mail->send()) { $message = 'Помилка'; } else { $message = 'Дані надіслані!'; } $response = ['message' => $message]; header('Content-type: application/json'); echo json_encode($response); ?>