Hi I'm using the standard phpmailer class with the smtp class and this handler:
Code:
<?
ob_start();
if(isset($_POST['btnSubmit']))
{
require("class.phpmailer.php");
$mail = new PHPMailer();
//Your SMTP servers details
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "mydetails"; // specify main and backup server or localhost
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mydetails"; // SMTP username
$mail->Password = "mydetails"; // SMTP password
//It should be same as that of the SMTP user
$redirect_url = "redirectdetails" ; //.$_SERVER['SERVER_NAME']; //Redirect URL after submit the form
$mail->From = $mail->Username; //Default From email same as smtp user
$mail->FromName = "test User";
$mail->AddAddress("email address to send to", "Name"); //Email address where you wish to receive/collect those emails.
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $_POST['subject'];
$message = "Hi[name]".$_POST['fullname']." \r\n <br>Email Adrress :".$_POST['email']." \r\n <br> \r \n".$_POST['query'];
$mail->Body = $message;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
header("Location: $redirect_url");
}
?>
What I'm trying to do is replace $mail->AddAddress("email address to send to", "Name"); with $mail->AddAddress(EMAIL NAME I WANT TO EMAIL);
I've tried:
$mail->AddAddress($contact_email);
$mail->AddAddress = $contact_email;
$mail->AddAddress $_POST['email']; (taken from the html form)
and nothing seems to work, I keep getting an error;
Message could not be sent.
Mailer Error: Language string failed to load: recipients_failed
Any help?
I'm trying to use the form to email my clients when I need to from my admin backend, the name and email are stored as variables of $contact_name & $contact_email
So the form will work in reverse, instead of sending all emails from them to me as a normal form would work, it will send them from me based on which client is loaded to their email address.
so not:
me@me.com instead
you@you.com so you receive the email and I dont.