Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Build a Basic PHP Website (2018) Adding a Basic Form Utilizing Object Properties and Methods

Mailer Error : Could not instantiate mail function.

it says "Mailer Error : Could not instantiate mail function." when i hit send here's my code :

    if (!PHPMailer::validateAddress($email)) // checkes if the email add is valid
    {
        echo "Invald email address.";
        exit;
    }

    $email_body = "";
    $email_body .= "Name " . $name . "\n";
    $email_body .= "Email " . $email . "\n";
    $email_body .= "Details message ". $details . "\n";

    $mail = new PHPMailer;

    $mail->setFrom('propsjane@gmail.com', $name);
    $mail->addReplyTo($email, $name);
    $mail->addAddress('propsjane@gmail.com', 'Jane');
    $mail->Subject = 'Library suggestion from ' . $name;
    $mail->Body = $email_body;
    if (!$mail->send())
    {
        // $msg .= "Mailer Error: " . $mail->ErrorInfo; ewan bat pinalitan
        echo "Mailer Error : " . $mail->ErrorInfo;
        exit;
    } 
    header("location:suggest.php?status=thanks");

1 Answer

Damir Paulić
Damir Paulić
6,591 Points

Had the same error, next video solves it!