Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- error_reporting(E_ALL);
- $from = 'DomainName@gmail.com';
- $to = 'mail@gmail.com';
- $from_name = 'DomainName.com';
- $subject = 'Selling domain DomainName.com';
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\Exception;
- use SMTP\SMTP\SMTP;
- require 'Exception.php';
- require 'PHPMailer.php';
- require 'SMTP.php';
- define('GUSER', 'emailsender@gmail.com');
- define('GPWD', '*******');
- function smtpmailer( $to, $from, $from_name, $subject, $body ) {
- $mail = new PHPMailer;
- $mail->IsSMTP();
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = 'ssl';
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 25;
- $mail->Username = GUSER;
- $mail->Password = GPWD;
- $mail->SetFrom( $from, $from_name );
- $mail->isHTML(true);
- $mail->Subject = $subject;
- $mail->Body = $body;
- $mail->AddAddress( $to );
- if ( !$mail->Send() ) {
- $status = 'Mail error: '.$mail->ErrorInfo;
- } else {
- $status = 'Message sent!';
- }
- echo $status;
- }
- $c = true;
- $data = json_decode(file_get_contents('php://input'), true);
- $message = null;
- foreach ( $data as $key => $value ) {
- if ( $value != "" ) {
- $message .= "
- " . ( ($c = !$c) ? '<tr>':'<tr style="background-color: #f8f8f8;">' ) . "
- <td style='padding: 10px; border: #e9e9e9 1px solid;'><b>$key</b></td>
- <td style='padding: 10px; border: #e9e9e9 1px solid;'>$value</td>
- </tr>
- ";
- }
- }
- $message = "<table style='width: 100%;'>$message</table>";
- smtpmailer($to, $from, $from_name, $subject, $message);
- ?>
Add Comment
Please, Sign In to add comment