2012-10-02 246 views
0

我在這裏看到了類似的問題,但是,我不beign能解決我的問題。 我試圖發送使用PHP郵件......但是這是行不通的。發送郵件使用PHP

<?php 
$email_from="[email protected]"; 
ini_set("sendmail_from", $email_from); 
$headers = "From: $email_from"; 
mail('[email protected]','Registration confirmation','Hihihihihihih','$headers'); 
?> 

它給了我一個Windows服務器上出現以下錯誤: 「SMTP服務器響應:這裏550沒有這樣的用戶在」

以後A的nginx服務器上的錯誤:

「服務器遇到一個內部錯誤或配置錯誤,無法完成您的請求。

請與服務器管理員聯繫,網站管理員,並通知他們錯誤發生的時間,以及任何你可能會做,可能導致了錯誤。

有關此錯誤的更多信息可能在服務器錯誤日誌中可用。

此外,試圖使用ErrorDocument來處理請求時遇到一個500內部服務器錯誤錯誤。」

+1

嘗試刪除周圍的單引號' '$ headers'' – DaveRandom

+0

仍然沒有工作:'( –

+0

你不需要刪除的ini_set行中ini_set行 – rsz

回答

1

你有你的發送郵件服務器設置?如果你在Windows上運行,你需要一個SMTP服務器,如果Linux上你必須配置sendmail或相似,並且在本地運行

的SMTP錯誤信息表明,它是開放轉發 - 在它不只是讓任何人問它發送電子郵件給某人/某處否則......這很好,因爲垃圾郵件發送者會使用它,它可能需要某種身份驗證離子(您的用戶名/密碼)前,將除了交付給任何人,但那些地方的機器(如託管在機器上域的電子郵件地址)的電子郵件。

不幸的是,PHP mail()方法不能處理,所以你需要看看第三方包 - PEAR mailPHPMailer是不錯的選擇。

要使用PHPMailer的完成任務:

require_once /*lib location*/"phpmailer/class.phpmailer.php"; 
require_once /*lib location*/"phpmailer/class.smtp.php"; 

$mail=new PHPMailer(); 
$mail->IsSMTP(); 
$mail->Host=/*Your host*/; 
$mail->Port=465;//For SSL - use this if you can 
$mail->SMTPAuth=true; 
$mail->SMTPSecure="ssl"; 
$mail->SMTPDebug=2;//Comment once it works, but the debug info is invaluable 
$mail->Username=/*Your username*/; 
$mail->Password=/*Your password*/; 
$mail->setFrom("[email protected]"); 
$mail->Subject='Registration confirmation'; 
$mail->Body='Hihihihihihih'; 
$mail->AddAddress('[email protected]'); 
$mail->Send(); 
+0

非常感謝你.....它的工作.. –