Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo apt install composer
- install phpmailer from composer
- composer require phpmailer/phpmailer
- 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->SMTPDebug = 4;
- $mail->isSMTP();
- $mail->Host = 'smtp.googlemail.com'; //gmail SMTP server
- $mail->SMTPAuth = true;
- $mail->Username = 'pacal75.2@gmail.com'; //username
- $mail->Password = 'Popolvuh2012'; //password
- $mail->SMTPSecure = 'ssl';
- $mail->Port = 465; //SMTP port
- $mail->setFrom('noreply@polotradez.net', 'Polotradez');
- $mail->addAddress('pacal75@gmail.com', 'User Name');
- $mail->isHTML(true);
- $mail->Subject = 'New Execute!';
- $mail->Body = '<html><body>
- <table style="border-collapse: collapse; width: 100%;" border="1">
- <tbody>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #339966;"><strong>NEW ORDER EXECUTE!</strong></span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>PAIRS</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">xxx</span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>TYPE</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">xxx</span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>AMOUNT</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">xxx</span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>DATE</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">xxx</span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>RATE</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">xxx</span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>TOTAL</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">xxx</span></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><strong>TRADEID</strong></td>
- </tr>
- <tr style="height: 21px;">
- <td style="width: 100%; text-align: center; height: 21px;"><span style="color: #ff0000;">XXX</span></td>
- </tr>
- </table></body></html>';
- if (!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- */
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->SMTPDebug = 3; // Enable verbose debug output
- $mail->Debugoutput = "error_log";
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->Port = 587; // TCP port to connect to
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->SMTPSecure = 'tsl'; // Enable TLS encryption, `ssl` also accepted
- $mail->Username = 'pacal75.2@gmail.com'; // SMTP username
- $mail->Password = 'Popolvuh2012'; // SMTP password
- $mail->SMTPOptions = array(
- 'ssl' => array(
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- )
- );
- //Recipients
- $mail->setFrom('pacal75.2@gmail.com', 'Mailer');
- $mail->addAddress('pacal75@gmail.com', 'Recipient User'); // Add a recipient
- $mail->addReplyTo('sender@example.com', 'Information');
- // $mail->addAddress('to@example.com'); // Name is optional
- // $mail->addCC('cc@example.com');
- // $mail->addBCC('bcc@example.com');
- //Attachments
- // $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->CharSet = "UTF-8";
- $mail->Subject = 'Here is the subject';
- $mail->Body = '<b>This is the HTML message body in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->WordWrap = 80;
- $mail->send();
- echo 'Message has been sent';
- }
- catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement