Having trouble with PHPMailer

后端 未结 7 1001
渐次进展
渐次进展 2020-11-28 09:24

I am trying to use PHPMailer to send a gmail email. I followed this post

In order to do this, I set up a function shown below:

function sendEmail($         


        
7条回答
  •  北海茫月
    2020-11-28 10:16

    $mail = new PHPMailer();
    
                    // Set up SMTP
                    $mail->IsSMTP();                // Sets up a SMTP connection
                    $mail->SMTPDebug  = 0;          // This will print debugging info
                    $mail->SMTPAuth = true;         // Connection with the SMTP does require authorization
                    $mail->SMTPSecure = "tls";      // Connect using a TLS connection
                    $mail->Host = "smtp.gmail.com";
                    $mail->Port = 587;
                    $mail->Encoding = '7bit';       // SMS uses 7-bit encoding
                    $mail->IsHTML(true);            // Set email format to HTML
    
                    // Authentication
                    $mail->Username   = "xxx@xxx.xxx.xx"; // Login
                    $mail->Password   = "xxxxxx"; // Password
    
                    //$to=
                    $to = "zzz@zzz.zzz.zz";
                    $mail->Subject = "Outstanding Balance Notification ";     // Subject (which isn't required)
                    $mail->Body =  "Dear Sir / Madam";
                    $mail->FromName = "stackoverflow";
                    $mail->From = "noreply@xxx.xxx.xx";
    
                    $mail->AddAddress($row["Email1"]);
    

    try this.. :)

提交回复
热议问题