简体   繁体   中英

How to send email to gmail using PHP Mailer?

I need to send mail using PHP Mailer.

Mail is sending but not received in gmail. In phpmailer folder i have 3 files: class.phpmailer.php, class.smtp.php, PHPMailerAutoload.php

require 'phpmailer/PHPMailerAutoload.php';

    $mail = new PHPMailer;
    $mail->isSMTP();

    $mail->Host='smtp.gmail.com';
    $mail->Port=587;
    $mail->SMTPAuth=true;
    $mail->SMTPSecure='tls';

    $mail->Username='mail@gmail.com';
    $mail->Password='password';

    $mail->setFrom('mail@gmail.com','Company');
    $mail->addAddress('company@gmail.com');
    $mail->addReplyTo('mail@gmail.com');

    $mail->isHTML(true);
    $mail->Subject='New Form Submission';
    $mail->Body='<h1>Hello</h1>';

    header("Location: ../123.php");

Try using the debug mode in PHPMailer: https://github.com/PHPMailer/PHPMailer/wiki/SMTP-Debugging

This will show you additional information on the exchange.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM