Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailerPHPMailer;
- use PHPMailerException;
- require 'PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer(true);
- try {
- //Server settings
- $mail->SMTPDebug = 4;
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'thisismy@gmail.com';
- $mail->Password = 'xxxxxxxx';
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- //Recipients
- $mail->setFrom('from@example.com', 'Mailer');
- $mail->addAddress('receiver@gmail.com');
- //Content
- $mail->isHTML(true);
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
- }
- ?>
Add Comment
Please, Sign In to add comment