在我的網站上提交表格后,我使用如下行發送電子郵件。到目前為止,一切都按預期工作。現在我想設置自己的服務器,并希望避免在此服務器上設置電子郵件客戶端。有人可以告訴我必須在此處添加什么才能將其設置為使用郵件服務器嗎?這是否使用 IP 地址工作,或者我是否需要額外的 PHP 文件來進行這種設置?注意:我的電子郵件將只包含文本和一些基本的 HTML,沒有附件。我是 PHP 的新手,希望能在這里得到一些入門幫助。我的 PHP(縮寫):// get submitted form data$postData = $_POST;// retrieve some post data to include in emailunset($postData);// prepare email$to = '[email protected]'; $subject = 'Some text';$emailBody = '<html><body>Some HTML text</body></html>'; $headers = 'From: Someone <[email protected]>' . PHP_EOL . 'Cc: [email protected] <[email protected]>' . PHP_EOL . 'Reply-To: [email protected] <[email protected]>' . PHP_EOL . 'X-Mailer: PHP/' . phpversion(); // set content-type header for sending HTML email$headers .= "\r\n". "MIME-Version: 1.0";$headers .= "\r\n". "Content-type:text/html;charset=UTF-8";// send email$mail = mail($to, $subject, $emailBody, $headers);if($mail) { header('Location: support.php?status=emailSent');}非常感謝,湯姆
PHP:如何修改工作電子郵件腳本以在自己的服務器上運行
慕田峪9158850
2023-04-21 15:29:01