doufei5537
2014-12-25 10:39
浏览 54

PHPMailer不在XAMPP中工作

So I've tried a couple of things but it I'm just unable to send a mail from php on my XAMPP server. I'm using OSX Yosemite and in terminal I can mail to the local mail client which I've setup and also to my external mail. I even switched to Netbeans IDE and tried the code in it's built in php server which worked but on my xampp server it just doesn't send. I've been trying to use PHPMailer send an email but it doesn't seem to work everything seems fine.

    $mail->IsSMTP(); // enable SMTP
    $mail->SMTPDebug = 3; // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true; // authentication enabled
    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail
    $mail->Host = "HOST_ADDRESS";
    $mail->Port = 465; // or 587
    $mail->IsHTML(true);
    $mail->Username = "HOST_USER";
    $mail->Password = "HOST_PASSWORD";
    $mail->SetFrom("donotreply@webgroup.com", "Account Confirmation");
    $mail->Subject = $subject;
    $mail->Body = $email_body;
    $mail->AddAddress($address);

Whenever I send a mail I get this error:

SMTP Failed to connect to server(0)

Any help? Have been trying to figure this out for hours now

图片转代码服务由CSDN问答提供 功能建议

所以我尝试了几件事,但我只是无法从我的PHP发送邮件 XAMPP服务器。 我正在使用OSX Yosemite,在终端我可以邮寄到我设置的本地邮件客户端以及我的外部邮件。 我甚至切换到Netbeans IDE并尝试了它内置的php服务器中的代码,但是在我的xampp服务器上它只是不发送。 我一直在尝试使用PHPMailer发送电子邮件,但它似乎没有工作似乎一切正常。

  $ mail-> IsSMTP();  //启用SMTP 
 $ mail-> SMTPDebug = 3;  //调试:1 =错误和消息,2 =仅消息
 $ mail-> SMTPAuth = true;  //启用身份验证
 $ mail-> SMTPSecure ='ssl';  //安全传输已启用GMail 
 $ mail-> Host =“HOST_ADDRESS”; 
 $ mail-> Port = 465;  //或587 
 $ mail-> IsHTML(true); 
 $ mail-> Username =“HOST_USER”; 
 $ mail-> Password =“HOST_PASSWORD”; 
 $ mail-> SetFrom  (“donotreply@webgroup.com”,“帐户确认”); 
 $ mail-> Subject = $ subject; 
 $ mail-> Body = $ email_body; 
 $ mail-> AddAddress($ address)  ); 
   
 
 

每当我发送邮件时都会收到此错误:

  SMTP无法连接到服务器(  0)
   
 
 

任何帮助? 一直试图解决这个问题几个小时

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

  • duanou9758 2014-12-25 10:47
    最佳回答

    Configure SMTP Server first to send the email. SMTP configuration is necessary to work the mail function.

    http://www.tutorialspoint.com/php/php_sending_emails.htm

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题