Dear all,
I have done a website that I need to integrate emailing functionality.
I have done this before, and it worked perfectly, and still does.
However, when I attempted to use the same code to test the emailing functionality for the new site, I get an error message as below;
"Mailer Error: The following From address failed: recipient@gmail.com : Called Mail() without being connected"
Here is the code that I am using.
<?php
require("PHPMailer_5.2.4/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "localhost";
$mail->From = $_POST['email'];
$mail->FromName = $_POST['sender_name'];
$email_add = $_POST['email'];
$phone_number = $_POST['phone_number'];
$name = $_POST['name'];
$subject = $_POST['subject'];
$msg = $_POST['email_message']."\n".$name.".";
$mail->AddBCC("cc_recepient@gmail.com");
$mail->AddAddress("recepient@gmail.com");
$mail->SMTPAuth = "true";
$mail->Username = "my_gmail@gmail.com";
$mail->Password = "my_gmail_password";
$mail->Port = "25";
$mail->name = $name;
$mail->phone_number = $phone_number;
$mail->Subject = $subject;
$mail->Body = $msg;
$mail->WordWrap = 50;
if(!$mail->Send())
{
echo "<script language='javascript'>
alert('Your email was NOT sent! Please try again.')
</script>
<script>
window.location='contact_us.php'
</script>";
}
else
{
echo "<script language='javascript'>
alert('Mail Successfully sent! Thank you for contacting us.')
</script>
<script>
window.location='contact_us.php'
</script>";
}
// $email = $_REQUEST['email'] ;
// $message = $_REQUEST['message'] ;
?>
I added the line;
echo 'Mailer Error: ' . $mail->ErrorInfo;
to identify the problem, and it shows me the error mentioned above.
I dunno what I am doing wrong since the same code is working fine elsewhere.