2012-05-04 70 views
8

我使用mail發送來自PHP的電子郵件。它工作正常,但現在我需要使用更安全的郵件服務器。身份驗證php郵件

我需要使用以下配置郵件服務器連接:

smtp: "mail.newserver.com" 
port: "25" 
timeout: 60 
auth: yes 
user: name 
pass: word 

我應該如何改變我下面的代碼,以便它與上述配置工作?

$to = $SendTo; 
$headers = "From: <[email protected]>" . "\r\n" . "X-Mailer: php"; 
$subject = "Website Contact : " . $uxGlobalLocation; 
$body = $Bodycopy; 

if (mail($to, $subject, $body, $headers)) { 
    header ('Location: /index.php?option'); 
    exit(); 
} else { 
    echo("<p>Message delivery failed...</p>"); 
} 

回答

6

內置的mail()功能不提供任何形式的認證。您需要使用提供SMTP驗證的第三方庫。熱門的選擇包括:

您還可以在Packagist搜索作曲家包。