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

Ana Camelo
PLUS
Ana Camelo
Courses Plus Student 13,218 Points

Sending Email

I'm using PHPMailer to send an email, but when I'm going to send it, the following message appears:

Fatal error: Call to undefined method PHPMailer::SetForm()

The line code corresponding to the line mentioned in the error is this one:

$mail->SetFrom($email, $name);

Does anyone know why is that a fatal error and how can I fix it?

Thanks a lot!

3 Answers

Hi Ana

What version of PHPMailer are you using?

try this with the code you have.

Or it might be worth trying to replace: $mail->SetFrom($email, $name);

With: $mail->From = $email; $mail->FromName = $name;

Fatal error: Call to undefined method PHPMailer::Set*Form*()

The line code corresponding to the line mentioned in the error is this one:

$mail->Set*From*($email, $name);

Form != From... Unless im missing something else or the typo is in your post.

Please Help...!!! I am able to send mail to .com id's but not on .in id's . Following is my code:

<?php $to = 'sunil.gemini@knowledgewoods.in'; $subject = 'New Enquiry'; $msg = "<html> <head> <title>KnowledgeWoods Consulting</title> </head>

<body> <table border=\"1\" bgcolor=\"#ffffff\">

<tr> <td>Name</td> <td>$name</td> </tr>

<tr> <td>Email</td> <td>$email </td> </tr>

<tr> <td>Phone No.</td> <td>$contact</td> </tr>

<tr> <td>Enquiry</td> <td>$comment</td> </tr>

</table> </body> </html>";

// Make sure to escape quotes

$headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Marketing' . "\r\n";

mail($to, $subject, $msg, $headers);

?>