Advertisement
Guest User

Untitled

a guest
Dec 17th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'class.phpmailer.php';
  3. $mail = new PHPMailer();
  4.  
  5. $email = $_POST['email'];
  6. $name = $_POST['name'];                      
  7.  
  8. $mail->isSMTP();                                      
  9. $mail->Host = 'smtp.gmail.com';                       // если отправка через gmail
  10. $mail->SMTPAuth = true;                              
  11. $mail->Username = 'user@example.com';                 // мыло отправителя
  12. $mail->Password = 'secret';                           // пароль отправителя
  13. $mail->SMTPSecure = 'ssl';                            
  14. $mail->Port = 465;                                    
  15.  
  16. $mail->setFrom('from@example.com', 'Mailer');         // от кого
  17. $mail->addAddress('ellen@example.com');               // кому
  18.  
  19. $mail->isHTML(true);                                  
  20.  
  21. $mail->Subject = 'Here is the subject';               // заголовок
  22. $mail->Body    = 'Спасибо за регистрацию, ' . $name . '. Ваш email: ' . $email;      // тут html тело письма
  23.  
  24.  
  25. if(!$mail->send()) {
  26.     $data = ['success' => true, 'message' => 'Успешно отправлено'];
  27. } else {
  28.     $data = ['success' => false, 'message' => 'Что-то пошло не так. Попробуйте позже'];
  29. }
  30.  
  31. header('Content-Type: application/json');
  32. echo json_encode($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement