Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'phpmailer/class.phpmailer.php';
- $mail = new PHPMailer;
- $mail->IsSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup server
- $mail->Port = 465; // Set the SMTP port
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'USERNAME'; // SMTP username
- $mail->Password = 'APIKEY'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
- $mail->From = 'from@example.com';
- $mail->FromName = 'Your From name';
- $mail->AddAddress('josh@example.net', 'Josh Adams'); // Add a recipient
- $mail->AddAddress('ellen@example.com'); // Name is optional
- $mail->IsHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if(!$mail->Send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- exit;
- }
- echo 'Message has been sent';
Add Comment
Please, Sign In to add comment