Tikkie Posted January 10, 2014 Share Posted January 10, 2014 I'm new to PHP and working on a mailform with phpmailer with attachment. Everything works fine but the received mail keeps having my Gmail address in the from header. The AddReplyTo address works fine but I don't want to show the gmail address. This is what my code looks like: require('C:\xampp\htdocs\PHPMailer\class.phpmailer.php'); $mail = new PHPMailer(); // create a new object $mail->IsSMTP(); // enable SMTP $mail->SMTPDebug = 2; // debugging: 1 = errors and messages, 2 = messages only $mail->SMTPAuth = true; // authentication enabled $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail $mail->Host = 'smtp.gmail.com'; $mail->Port = 465; $mail->Username = 'myaccount@gmail.com'; $mail->Password = 'mypassword'; $mail->SetFrom('e-mail@address.com', 'email@address.com'); $mail->AddReplyTo('e-mail@address.com', 'e-mail@address.com'); $mail->AddAddress("myaccount@gmail.com", "MyAccount"); $mail->Subject = "TestMail"; $mail->Body = "This is the message body"; $mail->AddAttachment("test.txt", "test.txt"); // optional name if(!$mail->Send()) { echo "Error"; exit; } else { echo "OK"; } I only want to use the gmail smtp but want to show another e-mail address (e-mail@address.com in thie example) in the header. But it keeps showing myaccount@gmail.com. Also in the class.phpmailer.php I've configurated the $From, $FromName and $Sender as e-mail@address.com but this doesn't work. Can somebody help me with this? Quote Link to comment https://forums.phpfreaks.com/topic/285258-phpmailer-from-header/ Share on other sites More sharing options...
jazzman1 Posted January 10, 2014 Share Posted January 10, 2014 GMail restricts using random addresses from your personal account. To change that, open up your gmail account and add another mail address you own. Settings -> Accounts -> Add another email address you own Quote Link to comment https://forums.phpfreaks.com/topic/285258-phpmailer-from-header/#findComment-1464704 Share on other sites More sharing options...
Tikkie Posted January 10, 2014 Author Share Posted January 10, 2014 Thank you so much! I would never have searched there! Quote Link to comment https://forums.phpfreaks.com/topic/285258-phpmailer-from-header/#findComment-1464720 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.