邮件无法发送.Mailer错误:SMTP连接()失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

时间:2017-08-02 14:08:17

标签: phpmailer

    <?php
    require 'PHPMailerAutoload.php';

    $mail = new PHPMailer;

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

$mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'bobbygotecha07@.com';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'bobbygotecha07@example.com';                 // SMTP username
    $mail->Password = 'password';                           // SMTP password
    $mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to
    $mail->SMTPSecure = 'ssl';
    $mail->setFrom('bobbygotecha07@gmail.com', 'bobby gotecha');
    //$mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
    $mail->addAddress('bobbygotecha07@gmail.com');               // Name is optional
    $mail->addReplyTo('bobbygotecha07@gmail.com', 'Information');
    //$mail->addCC('cc@example.com');
    //$mail->addBCC('bcc@example.com');

    //$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';
    }
    ?>

这是我编写的用于发送邮件的代码,但它不适用于我,我也尝试了在stackoverflow中提到的varoius事件,但它没有woking,我也更新了dll文件但如果有人可以帮助我,仍然无法发送。

0 个答案:

没有答案