我爲我的網站使用iPage,並使用簡單的mail()方法從我的頁面發送測試郵件。在iPage上,我通過[email protected]提供電子郵件功能。但是當我發送一封電子郵件時,它來自iPage服務器,並從[email protected]發送,這看起來相當醜陋!使用PHP的mail()方法,我該如何設置發件人?
有沒有一種方法可以使用PHP中的mail()方法從我的頁面發送電子郵件,使用上面較短的發件人?感謝您的幫助!
我爲我的網站使用iPage,並使用簡單的mail()方法從我的頁面發送測試郵件。在iPage上,我通過[email protected]提供電子郵件功能。但是當我發送一封電子郵件時,它來自iPage服務器,並從[email protected]發送,這看起來相當醜陋!使用PHP的mail()方法,我該如何設置發件人?
有沒有一種方法可以使用PHP中的mail()方法從我的頁面發送電子郵件,使用上面較短的發件人?感謝您的幫助!
您需要添加名爲From的標頭。這個代碼將與郵件地址發送[email protected]:
$to = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
+1爲你打我! –
這個作品很棒! – Mark
'電子郵件( 「[email protected]」, 「HW」,的 「Hello World」, 「來源:[email protected]」?' –
有一種可能性,無論您使用的是託管服務無法發送帶有自定義「from」設置的郵件 –