Codeigniter PHP Mailer, Sender Info

305 views Asked by At

I'm using Codeigniter PHP Mailer which is hosted here: https://github.com/ivantcholakov/codeigniter-phpmailer/ and with gmail smtp it works flawless. However,using it for a standard contact form, when visitors use that contact form and send us an email, they basically send mails from our mail address to our another mail addess. When they open their own email address, they wont be seeing what they sent in their own sent items. What I want to do is (maybe without using smtp settings) show the visitors own mail adress (the one I'm asking as an input on contact form) as the FROM part of the email I receive from my contact form. So that, in case I want to reply the mail, hitting the reply button would be enough. İnstead of doing coding tricks and showing their email somewhere I could copy/paste and send new email.

1

There are 1 answers

2
Synchro On BEST ANSWER

Don't do that. It's effectively forging the from address and will fail SPF checks. Instead, use your own address as the From address, and add the submitted address as a reply-to address. In PHPMailer:

$mail->From = '[email protected]';
$mail->addReplyTo($POST['emailfrom']);