我有一個SMTP問題。我創建了一個PHP腳本來發送電子郵件。要求是我需要發送來自'[email protected]'的電子郵件,但我需要回復來'[email protected]'在電子郵件中設置replyTo字段
我在reply-to
標題字段中添加了[email protected]
。我遇到的唯一問題是,當有人收到電子郵件並單擊答覆按鈕時,[email protected]
和[email protected]
都顯示在TO
字段中。
是否有任何方法可以將[email protected]
從TO字段中刪除,並且只顯示在reply-to
字段中指定的電子郵件地址?
我使用的PHPMailer和代碼如下:
$this->phpmailer->IsSMTP();
$this->phpmailer->Host = $server;
$this->phpmailer->Port = $port;
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is [email protected]
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is [email protected]
$this->phpmailer->Subject = $subject;
$this->phpmailer->AltBody = $msgTXT; // non-html text
$this->phpmailer->MsgHTML($msgHTML); // html body-text
$this->phpmailer->AddAddress($email);
這聽起來像一個好主意,我會檢查它,並讓你知道它是如何去 –
是的,但它是一種「黑客」,所以你不需要編輯phpmailer。如果您只需發送一封普通電子郵件,則還可以完全停止使用phpmailer,並執行以下操作: 郵件('[email protected]','郵件主題','電子郵件正文','From:from.address @ example.com \ n回覆至:[email protected]「); 但您的服務器必須配置爲使用mail()。 – rationalboss
需要注意的是,調用$ this-> phpmailer-> MsgHTML($ msgHTML)會同時設置AltBody,所以會有效地清除前一行中設置的AltBody – bumperbox