Reputation: 316
I have 3 mail ids say, [email protected], [email protected] and [email protected]. I have setup PHPMailer with SMTP user as [email protected]. Now I set an auto response to [email protected]. When I send a mail from [email protected] to [email protected], autoresponse is going to [email protected], the address i used to configure SMTP. How can I make autoresponse to send to FROM address?
$mail->isSMTP();
$mail->Host = 'hostname';
$mail->SMTPAuth = true;
$mail->Username = '[email protected]';
$mail->Password = 'password';
$mail->SMTPSecure = '';
$mail->Port = 25;
$mail->Sender='[email protected]';
$mail->AddReplyTo('[email protected]', 'User2');
$mail->setFrom('[email protected]', 'User2', FALSE);
$mail->addAddress('[email protected]', 'User3');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $mailBody;
$mail->send();
Upvotes: 0
Views: 50
Reputation: 37770
You have not set a to
address, so it's falling back to a default.
$mail->addAddress('[email protected]');
Many ISPs (for example gmail) will not allow you to set arbitrary from addresses, so if your from address is not working, check that. Also, be sure not to forge from addresses as it will cause delivery failures when you break SPF rules.
If you're writing an autoresponder, check that the inbound message you're responding to does not have a Precedence: bulk
header set; autoresponses should not be sent to mailing lists (which should set that header) as it will often cause loops.
Upvotes: 1