Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //add to composer.json "phpmailer/phpmailer": "~5.2"
- require_once 'vendor/autoload.php';
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->Mailer = 'smtp';
- $mail->SMTPAuth = true;
- $mail->Host = 'smtp.gmail.com'; // "ssl://smtp.gmail.com" didn't worked
- $mail->SMTPSecure = 'tls'; // or 'ssl'
- $mail->Port = 587; //465 for ssl
- $mail->Username = "mahedi2014@gmail.com";
- $mail->Password = ""; //your gmail password
- $mail->IsHTML(true); // if you are going to send HTML formatted emails
- $mail->SingleTo = true; // if you want to send a same email one-by-one to multiple users in .
- $mail->From = "mahedi2014@gmail.com";
- $mail->FromName = "Your Name";
- $mail->addAddress("mahedi201422@gmail.com","User 1");
- $mail->addAddress("mahedi2014222@gmail.com","User 2");
- $mail->addCC("mahedi20141@gmail.com","User 3");
- $mail->addBCC("mahedi20142@gmail.com","User 4");
- $mail->Subject = "Testing PHPMailer with localhost";
- $mail->Body = "Hi,<br /><br />This system is working perfectly.";
- if(!$mail->Send())
- echo "Message was not sent <br />PHPMailer Error: " . $mail->ErrorInfo;
- else
- echo "Message has been sent";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement