sender email , name not received. phpmailer
message says email sent, cant sender email or sender name. received body , subject.
thanks
<?php require 'phpmailerautoload.php'; $name = $_post['fname']; $mail = $_post['email']; $subject = $_post['subj']; $message = $_post['mssg']; $mail = new phpmailer; $mail->issmtp(); // set mailer use smtp $mail->host = 'xxxxhost.com'; // specify main , backup smtp servers $mail->smtpauth = true; // enable smtp authentication $mail->username = 'xxxxxx@host.com'; // smtp username $mail->password = 'xxxxxxxxxxxx'; // smtp password $mail->smtpsecure = 'tls'; // enable tls encryption, `ssl` accepted $mail->port = 25; // tcp port connect $mail->setfrom($mail, $name); // value not received // add recipient $mail->addaddress('support@example.com'); // name optional $mail->ishtml(true); // set email format html $mail->subject = $subject; $mail->body = $message; if(!$mail->send()) { echo 'message not sent.'; echo 'mailer error: ' . $mail->errorinfo; } else { echo 'message has been sent'; } ?>
you question isn't clear, i'll take guess @ you're asking.
don't use submitter's email address address. it's forgery , mean rejected spf violations or end in spam folders. gmail doesn't let use arbitrary addresses reason (though can predefine aliases in gmail prefs) , use username address instead.
set submitter's address reply-to (see addreplyto()
in phpmailer) , own address address. way won't forging anything, , replies go right place. this:
$mail->addreplyto($_post['email'], $_post['name']); $mail->setfrom('me@example.com', 'my name');
it's idea put values message body in case it's invalid email address due simple typo, example user @example.com
. reply-to not work, you'll still have data.
Comments
Post a Comment