正如標題所說。這是我的功能:
<?php
//---------------EMAIL PORTION--------------------
error_reporting(E_ALL);
ini_set('display_errors', 'On');
set_error_handler("var_dump");
$from_email = '[email protected]';
$to = '[email protected]';
$subject = "XXXXXXXXXXX";
$message =
'
<html>
<body>
<div style="padding:10px 20px;">
<h3>Hello Person, </h3>
<img src="###########"/>
</div>
</body>
</html>
';
// Headers
$headers = "MIME-Version: 1.0\r\n"; // Defining the MIME version
$headers .= "Content-type: text/html\r\n";
$headers .= "From: \"XXXXXXXXXXXXXX\" <".$from_email.">\r\n"; // Sender Email
$headers .= "Reply-To: " . $from_email . "\r\n";
$sentMailResult = mail($to,$subject,$message,$headers);
if($sentMailResult) {
echo "Email Sent Successfully: ", $sentMailResult;
}
else {
die("Sorry but the email could not be sent, Please go back and try again!");
}
有時它會起作用,但大多數時候它不起作用。我將在瀏覽器的 php 頁面上,我會重繪 它,它會說電子郵件發送成功。然后我會重繪 它,它會說失敗。我正在為我的服務器使用 Xampp。當它失敗時,我在服務器日志中得到以下資訊:
sendmail: Error during delivery: TLS 1.0 and 1.1 are not supported. Please upgrade/update your client to support TLS 1.2. Visit https://aka.ms/smtp_auth_tls. [prod.outlook.com]
然后當它作業時,我的郵件日志在電子郵件資訊之后有這個:
250 2.0.0 OK
QUIT
I have done everything I can think of and I am beyond confused. I have tried adding this line onto my httpd-ssl.conf file: SSLProtocol all TLSv1.2 But it doesn't seem to help. I don't understand why it can work sometimes but not all the time. My php.ini mail function should be set up correctly and it links to a sendmail folder and the ini in there should also be setup correctly.
Any help would be greatly appreciated.
Update:
Apache version: 2.4.51
PHP version: 8.0.13
OpenSSL version: 1.1.1l
uj5u.com熱心網友回復:
我在這方面花了很多時間,并從比我聰明得多的人那里得到了幫助,但它從來沒有奏效。PHPMailer 是要走的路。設定它,第一次嘗試就成功了,此后一直有效。您甚至不必處理任何 ini 檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/422124.html
標籤:
