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 trialibbhfsmeaf
4,568 PointsWhy am I getting this error? PHPMailer
Here is the error I get when I submit my form: Fatal error: Class 'SMTP' not found in C:\xampp\htdocs\Portfolio\PHPMailer-master\class.phpmailer.php on line 1203
I don't even have 1203 lines of code. The error they are speaking of would be on line 18, but why am I receiving it in the first place? That file path is correct..
Here is the code:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$email = $_POST["email"];
$website_description = $_POST["website_description"];
$design_description = $_POST["design_description"];
$email_body = "";
$divider = "----------------------------------------";
$email_body = $email_body . "First Name: " . $first_name . "\n\n" . $divider . "\n\n";
$email_body = $email_body . "Last Name: " . $last_name . "\n\n" . $divider . "\n\n";
$email_body = $email_body . "Email: " . $email . "\n\n" . $divider . "\n\n";
$email_body = $email_body . "Website Description: " . $website_description . "\n\n" . $divider . "\n\n";
$email_body = $email_body . "Design Description: " . $design_description;
require_once('C:\xampp\htdocs\Portfolio\PHPMailer-master\class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = "send.one.com";
$mail->Port = 587;
$mail->Username = "camara@desimara.com";
$mail->Password = "xxxxxxxx";
$message = $email_body;
$mail->SetFrom($email, 'Website Request');
$mail->Subject = "Website Request Confirmation";
$mail->MsgHTML($message);
$mail->AddAddress('camara@desimara.com', 'Lansana Camara');
if($mail->Send()) {
echo "Message sent!";
} else {
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
?>
ibbhfsmeaf
4,568 PointsI've done what you said. Now this is the new error I'm getting: Mailer Error: SMTP Error: The following recipients failed: camara@desimara.com
That is my correct email. Any suggestions?
anthony crowell
Courses Plus Student 10,953 PointsI can't see all your code but are you sure the port shouldn't be 25? Also http://desimara.com/ is registered to one.com and you are trying to run scripts from your local windows drive without that server being registered and a return path I'm not sure that would work the way you want. If you are putting this on their server and running it I would look at your php.ini file through their control panel and find out what version of php they are running, my guess is 5.3 or 5.4 in either case the path for the files probable isn't going to match with xampp.
1 Answer
ibbhfsmeaf
4,568 PointsFixed my problem! All I had to do was comment out $mail->IsSMTP();
anthony crowell
Courses Plus Student 10,953 Pointsanthony crowell
Courses Plus Student 10,953 PointsHi did you check the script under your mikes tshirt directories? In the inc directory you should have a phpmailer directory and in that is the class.phpmailer.php file you are looking for. You may need to download all files for that project.