Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Use composer to autoload PHPMailer or else require their integrated autoloader...
- $data = (object) [
- 'username' => 'your.email@gmail.com',
- 'password' => 'generated_app_password'
- ];
- $phpmailer = samplePHPMailer($data);
- function samplePHPMailer ($credentials) {
- $mailer = new PHPMailer;
- $mailer->isSMTP();
- $mailer->SMTPDebug = 2;
- $mailer->Debugoutput = 'html';
- $mailer->SMTPOptions = [
- 'ssl' => [
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- ]
- ];
- $mailer->Host = 'smtp.gmail.com';
- $mailer->Port = 587;
- $mailer->SMTPSecure = 'tls';
- $mailer->SMTPAuth = true;
- $mailer->Username = $credentials->username;
- $mailer->Password = $credentials->password;
- $mailer->setFrom($credentials->username, 'Inspot Gaming');
- $mailer->addReplyTo($credentials->username, 'Inspot Gaming');
- $mailer->addAddress('n.dvLden@gmail.com'); // send to whom...
- $mailer->Subject = 'Sample Test';
- $mailer->Body = 'This is sample non-HTML test...';
- $mailer->AltBody = 'Some alt body goes here...';
- return !$mailer->send()
- ? false
- : true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement