用php發送email的有關問題

來源:互聯網
上載者:User
用php發送email的問題

//replace these next two variable with your email address and your web address
$yourEmailAddress = "[email protected]";
$yourWebAddress = "www.cyhzxx.com";

//collect Posted variables
$name = $_POST['Name'];
$email = $_POST['Email'];
$message = $_POST['Message'];
//generic subject
$subject = "Message From Visitor";
//header
$header = 'From: '. $yourWebAddress . "\r\n" . 'Content-Type: text/html; charset=ISO-8859-1';
//email
$htmlEmail = "




Message from site visitor

Name : ".$name."

Email : ".$email."


Message :".$message."



";
//php mail function
mail($yourEmailAddress,$subject,$htmlEmail,$header);
echo("Message Sent!");
?>

大家看一下吧,意思就是 想把 別的頁面提交過來的 資訊 發送到我的郵箱 ,html我熟悉,但是php一點都不懂,這個代碼源檔案是 .php的,只有這些代碼, 希望可以幫我講解下這是怎麼發送郵件的,而且 事實是這些代碼沒有作用,我的郵箱並沒有收到郵件

------解決方案--------------------
關於email的內容,一般書上介紹的較為簡潔。
$yourEmailAddress = "[email protected]";
$yourWebAddress = "www.cyhzxx.com";
以上為變數賦值
$name = $_POST['Name'];
$email = $_POST['Email'];
$message = $_POST['Message'];
以上為POST表單擷取
Message from site visitor

等4句為顯示獲得的表單資訊
mail($yourEmailAddress,$subject,$htmlEmail,$header);
第一個參數:被發送地址;第二個參數:訊息的主題,第三個:訊息內容,貌似第四個: form來自哪個地址。
這麼說清楚了吧,你的代碼上面有。
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.