dqo58772 2012-11-26 21:25
浏览 97
已采纳

无法在wamp中使用假sendmail发送电子邮件

I have been doing this for hours and can't get it to work, many comments in the tutorial said it works like a charm but I can't really make this work.

I have done all the steps here http://blog.techwheels.net/send-email-from-localhost-wamp-server-using-sendmail/ and read all the comments with problems other users encountered and also used the solutions replied.

What I see on the apache error log is this

[Tue Nov 27 05:19:47 2012] [notice] Parent: Created child process 4120
[Tue Nov 27 05:19:47 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Child process is running
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Acquired the start mutex.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting 64 worker threads.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting thread to listen on port 80.
[Tue Nov 27 05:19:48 2012] [notice] Child 4120: Starting thread to listen on port 80.

I also have tried it on my other computer and it has the same error log. I have disabled my firewall and also critically followed the steps on the tutorial.

  • 写回答

1条回答 默认 最新

  • drb88830 2012-11-27 10:57
    关注

    Sorry for the previous answer. Thanks everyone for your suggestions to improve my answer. Here is my answer: The phpmailer has a file called class.phpmailer.php. Then in the function smtpmailer($to, $from, $from_name, $subject, $body) the code goes as follows:

    global $error;
    $mail = new PHPMailer(); 
    $mail->IsSMTP(); 
    $mail->SMTPDebug = 0; 
    $mail->SMTPAuth = true;  
    $mail->SMTPSecure = 'ssl'; 
    $mail->Host = 'smtp.gmail.com';
    $mail->Port = 465; 
    $mail->Username = 'gmailusername';  
    $mail->Password = 'gmailpassword';           
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
        $mail->IsHTML(True);
        $mail->Body=$body;
    //$mail->Body = $body;
    $mail->AddAddress($to);
    if(!$mail->Send()) {
        $error = 'Mail error: '.$mail->ErrorInfo; 
        return false;
    } else {
        $error = 'Message sent!';
        return true;
    }
    

    Then just call the function where ever you want as: smtpmailer($to, $from, $headers, $subject, $message);

    Oh and prior to this make sure php_openssl extension is enabled.

    I hope this answer of mine was helpful. :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题