2017-04-03 78 views
-2

我試圖在我的私人投資組合網站上作出聯繫表格。聯繫表單和數據庫之間的鏈接已經完成。但是現在我想在有人發送填寫表單時收到郵件通知。與MySQL聯繫表格發送電子郵件時填寫表格

在此先感謝

+0

歡迎來到Stackoverflow!爲了獲得有用的答案,請包括您迄今嘗試解決此問題的代碼,以便我們幫助您調試或改進它。這就是工作原理。 – ITWitch

+0

有太多可能的答案,或者這個格式的答案太長。請添加詳細信息以縮小答案集或隔離可以用幾個段落回答的問題。我建議你找一個開發論壇(也許[Quora](http://www.quora.com/Computer-Programming?))來解決一般問題。然後,如果您有特定的編碼問題,請回到Stack Overflow,我們很樂意提供幫助。 –

回答

1

你可以簡單地使用:

mail($to,$subject,$message,$headers); 
+0

janfitz回答了這個問題,但是我使用的示例代碼是: '<?php $ to ='[email protected]'; $ subject ='電子郵件主題'; $ body ='在這裏寫下你的信息'; $ headers ='From:[email protected]'; 郵件($ to,$ subject,$ body,$ headers); ?> – Memristor

+0

missing ** header **「mail($ to,$ subject,$ message,$ headers);」 –

+0

謝謝你們 - 修好了 – janfitz

0

//多個收件人

$to = '[email protected], [email protected]'; // note the comma 

//主題

$subject = 'Birthday Reminders for August'; 

//消息

$message = ' 
<html> 
<head> 
    <title>Birthday Reminders for August</title> 
</head> 
<body> 
    <p>Here are the birthdays upcoming in August!</p> 
    <table> 
    <tr> 
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th> 
    </tr> 
    <tr> 
     <td>Johny</td><td>10th</td><td>August</td><td>1970</td> 
    </tr> 
    <tr> 
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td> 
    </tr> 
    </table> 
</body> 
</html> 
'; 

//要發送HTML郵件時,Content-type頭必須設置

$headers[] = 'MIME-Version: 1.0'; 
$headers[] = 'Content-type: text/html; charset=iso-8859-1'; 

//附加頭

$headers[] = 'To: Mary <[email protected]>, Kelly <[email protected]>'; 
$headers[] = 'From: Birthday Reminder <[email protected]>'; 
$headers[] = 'Cc: [email protected]'; 
$headers[] = 'Bcc: [email protected]'; 

//郵寄

mail($to, $subject, $message, implode("\r\n", $headers)); 

link