与MySQL联系表格发送电子邮件时填写表格

问题描述:

我试图在我的私人投资组合网站上作出联系表格。联系表单和数据库之间的链接已经完成。但是现在我想在有人发送填写表单时收到邮件通知。与MySQL联系表格发送电子邮件时填写表格

在此先感谢

+0

欢迎来到Stackoverflow!为了获得有用的答案,请包括您迄今尝试解决此问题的代码,以便我们帮助您调试或改进它。这就是工作原理。 – ITWitch

+0

有太多可能的答案,或者这个格式的答案太长。请添加详细信息以缩小答案集或隔离可以用几个段落回答的问题。我建议你找一个开发论坛(也许[Quora](http://www.quora.com/Computer-Programming?))来解决一般问题。然后,如果您有特定的编码问题,请回到Stack Overflow,我们很乐意提供帮助。 –

你可以简单地使用:

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

janfitz回答了这个问题,但是我使用的示例代码是: ' – Memristor

+0

missing ** header **“mail($ to,$ subject,$ message,$ headers);” –

+0

谢谢你们 - 修好了 – janfitz

//多个收件人

$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