2017-08-03 120 views
0
<?php 
    require 'PHPMailerAutoload.php'; 



    $mail = new PHPMailer; 

    // $mail->SMTPDebug = 2;        // Enable verbose debug output 


    $mail->isSMTP();          // Set mailer to use SMTP 
    $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers 
    $mail->SMTPAuth = true;        // Enable SMTP authentication 
    $mail->Username = '[email protected]';     // SMTP username 
    $mail->Password = '##RESIDENCY##';       // SMTP password 
    $mail->SMTPSecure = 'tls';       // Enable TLS encryption, `ssl` also accepted 
    $mail->Port = 25;         // TCP port to connect to 
    $mail->SMTPSecure = 'ssl'; 
    $mail->setFrom('[email protected]', 'naimish golakiya'); 
    //$mail->addAddress('[email protected]', 'Joe User');  // Add a recipient 
    $mail->addAddress('[email protected]');    // Name is optional 
    $mail->addReplyTo('[email protected]', 'Information'); 
    //$mail->addCC('[email protected]'); 
    //$mail->addBCC('[email protected]'); 

    //$mail->addAttachment('/var/tmp/file.tar.gz');   // Add attachments 
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name 
    $mail->isHTML(true);         // Set email format to HTML 

    $mail->Subject = 'Here is the subject'; 
    $mail->Body = 'This is the HTML message body <b>in bold!</b>'; 
    $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; 
    } else { 
    echo 'Message has been sent'; 
    } 

    ?> 

我试图通过PHPMailer的发送邮件,但其没有工作的人的话,请help.i从gitub下载TE phpmaile和我也尝试解决在stackoverflow中提到的amsweres之间的这个错误,但仍然不起作用。消息无法sent.Mailer错误:SMTP错误:无法连接到SMTP主机

回答

0

更新端口号码为587.另外,这些都是伪造凭证吗?

相关问题