PDA

View Full Version : php mail problem



michelle
12-14-2006, 02:49 PM
I read the other posts about this topic, but still can't get the code below to work. I had a web form that used the php code below working on my site over the summer.

I wasn't getting forms sent into me the last couple months, so I figured no
one was submitting, then I tested it and turns out the php code no longer works. I ran it locally and it was fine.

I would love some help. Any idea what is going on?



<?php
require("class.phpmailer.php");
$mail = new PHPMailer();

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.mySite.com";
$mail->SMTPAuth = true; //Turn on SMTP authentication
$mail->Username = "mySite.com"; //SMTP username
$mail->Password = "myPassword"; //SMTP password

$mail-> From = "emailaddress@mysite.com";
$mail->FromName = "The site";
$mail->AddAddress("responses@mysite.com", "The Site");
$mail->WordWrap = 50; //set word wrap

$mail->Subject = "Feedback from Site";
$mail->Body = '1 Place: ' .$_POST['1Place'] ."\n\n" .'2 Place: '.$_POST['2Place'] ."\n\n";


if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
?>

Pethens
12-14-2006, 09:43 PM
I can't see anything wrong with your code, but since I know that the PHP mail() function works for me, I would suggest trying


$mail->IsMail(); // telling the class to use mail()

instead of


$mail->IsSMTP(); // telling the class to use SMTP

And if that still doesn't work, use mail() directly, there may be a problem with PHPMailer.

Hope that helps,

Stephen

areidmtm
12-15-2006, 08:52 AM
Make sure the sending email actually exists and the user name and password is the same as you used to access that email address






$mail->Username = "user@domain.com"; //SMTP username
$mail->Password = "passsword"; //SMTP password

michelle
12-15-2006, 02:57 PM
Thanks!!

I had the username just set to my domain name. Once I put in a real email address it worked fine. For what it is worth, I also set the Host equal to localhost on the advice of the help desk.

Thanks so much for helping me out.