Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'class.phpmailer.php';
- $mail = new PHPMailer();
- $email = $_POST['email'];
- $name = $_POST['name'];
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com'; // если отправка через gmail
- $mail->SMTPAuth = true;
- $mail->Username = 'user@example.com'; // мыло отправителя
- $mail->Password = 'secret'; // пароль отправителя
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465;
- $mail->setFrom('from@example.com', 'Mailer'); // от кого
- $mail->addAddress('ellen@example.com'); // кому
- $mail->isHTML(true);
- $mail->Subject = 'Here is the subject'; // заголовок
- $mail->Body = 'Спасибо за регистрацию, ' . $name . '. Ваш email: ' . $email; // тут html тело письма
- if(!$mail->send()) {
- $data = ['success' => true, 'message' => 'Успешно отправлено'];
- } else {
- $data = ['success' => false, 'message' => 'Что-то пошло не так. Попробуйте позже'];
- }
- header('Content-Type: application/json');
- echo json_encode($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement