Guest User

Untitled

a guest
Jun 15th, 2018
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5.  
  6. $from = 'DomainName@gmail.com';
  7. $to = 'mail@gmail.com';
  8. $from_name = 'DomainName.com';
  9. $subject = 'Selling domain DomainName.com';
  10.  
  11. use PHPMailer\PHPMailer\PHPMailer;
  12. use PHPMailer\PHPMailer\Exception;
  13. use SMTP\SMTP\SMTP;
  14.  
  15. require 'Exception.php';
  16. require 'PHPMailer.php';
  17. require 'SMTP.php';
  18.  
  19. define('GUSER', 'emailsender@gmail.com');
  20. define('GPWD', '*******');
  21.  
  22. function smtpmailer( $to, $from, $from_name, $subject, $body ) {
  23. $mail = new PHPMailer;
  24. $mail->IsSMTP();
  25. $mail->SMTPDebug = 0;
  26. $mail->SMTPAuth = true;
  27. $mail->SMTPSecure = 'ssl';
  28. $mail->Host = 'smtp.gmail.com';
  29. $mail->Port = 25;
  30. $mail->Username = GUSER;
  31. $mail->Password = GPWD;
  32. $mail->SetFrom( $from, $from_name );
  33. $mail->isHTML(true);
  34. $mail->Subject = $subject;
  35. $mail->Body = $body;
  36. $mail->AddAddress( $to );
  37.  
  38. if ( !$mail->Send() ) {
  39. $status = 'Mail error: '.$mail->ErrorInfo;
  40. } else {
  41. $status = 'Message sent!';
  42. }
  43. echo $status;
  44. }
  45.  
  46. $c = true;
  47.  
  48. $data = json_decode(file_get_contents('php://input'), true);
  49.  
  50. $message = null;
  51.  
  52. foreach ( $data as $key => $value ) {
  53. if ( $value != "" ) {
  54. $message .= "
  55. " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
  56. <td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
  57. <td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
  58. </tr>
  59. ";
  60. }
  61. }
  62.  
  63. $message = "<table style='width: 100%;'>$message</table>";
  64.  
  65.  
  66. smtpmailer($to, $from, $from_name, $subject, $message);
  67. ?>
Add Comment
Please, Sign In to add comment