2010-07-15 58 views
0

我正在使用PHP郵件()函數,並且想要更改郵件來自何處的表單,即:從默認網站電子郵件到特定電子郵件地址。我使用Dreamhost作爲我的託管服務提供商。更改與PHP郵件功能相關的電子郵件

我已經試過這樣:

<?php 
$name = $_GET['name']; 
$email = $_GET['email']; 
$comment = $_GET['comment']; 
$todayis = date("l, F j, Y, g:i a") ; 
$subject = "A message sent on ".$todayis." from ".$name." via the playatics website"; 
$message = " Message: $comment \r \n From: $name \r \n Reply to: $email"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers .= 'From: Domain Name [email protected]' . "\r\n"; 

mail("[email protected]", $subject, $message); 

?> 
+0

這應該主要工作,除非你有一個不正確的格式的'From'頭。你應該有'域名<[email protected]>'。 – 2010-07-15 22:24:42

回答

0

不能直接回答你的問題,但檢查出PHPMailer,如果你打算做在PHP中發送一點點電子郵件。它使事情變得更加美好和容易:)

4

你從這裏回答問題。您正在設置變量$headers,但您在調用mail()函數時沒有使用它。

<?php 
$name = $_GET['name']; 
$email = $_GET['email']; 
$comment = $_GET['comment']; 
$todayis = date("l, F j, Y, g:i a") ; 
$subject = "A message sent on ".$todayis." from ".$name." via the playatics website"; 
$message = " Message: $comment \r \n From: $name \r \n Reply to: $email"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
$headers .= 'From: Domain Name [email protected]' . "\r\n"; 

mail("[email protected]", $subject, $message, $headers); 

?> 

這應該這樣做。

+0

神聖的canoli!哈哈!是的,我正在鬍鬚,這樣做!謝謝 – JoeM05 2010-07-15 23:47:23

+0

任何機會,你可以標記這個答案是正確的嗎? (我想你會在我的回答左邊看到一個複選標記。)只是表示這個問題將被標記爲關閉(並且我得到了一些答案的聲譽)。 – 2010-07-16 00:32:46

相關問題