Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

pups pups
pups pups
1,756 Points

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!