phpMailer: Could not instantiate mail function

前端 未结 2 1671
北荒
北荒 2021-01-26 18:36

I created a form that uses phpMailer to email the results to the website owner. Of course, before I add the owner\'s email address I use mine to test that the form works. When

相关标签:
2条回答
  • 2021-01-26 18:54

    Set $mail->SMTPDebug = 2; so you can see what the server has to say, and read the troubleshooting guide.

    You're using authentication without encryption, which is not a good combination and many servers won't allow that. Add this:

    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    

    You've based your code on an old example, so you're probably using an old version of PHPMailer too; get the latest from github.

    0 讨论(0)
  • 2021-01-26 19:02

    There are couple of things you should try and check with this particular error message:

    Make sure you can use regular php mail() function. Create a blank page and use the php mail() to send a test email. If that works, maybe its your SMTP that's having issues with the particular user domain. Setup gmail SMTP or a different SMTP to send emails:

    $mail->IsSMTP();
    $mail->Host = "smtp.domain.com";
    
    // optional
    // used only when SMTP requires authentication  
    $mail->SMTPAuth = true;
    $mail->Username = 'smtp_username';
    $mail->Password = 'smtp_password';
    

    Can you share your phpMailer source for us to view?

    0 讨论(0)
提交回复
热议问题