如何在PHP中使用mail()
函数发送电子邮件申请表?PHP电子邮件发送申请表
-7
A
回答
2
PHP邮件最简单。
<?php
$message = "This is my e-mail message.";
mail('[email protected]', 'Message subject', $message);
?>
的PEAR包Mail
和Mail_Mime
有很多有用的功能来发送邮件,也是如此。接受用户的输入,建立一条消息并发送。除此之外,我们需要知道您遇到了什么问题。
1
一个非常简单的联系表单可能看起来像这样。请注意,这仅仅用于演示。我不建议使用此原样:
<?php
// If our form has been submitted
if ($_POST["submit"]) {
// Gather up some values
$name = $_POST["username"];
$msg = $_POST["message"];
$errors = false;
// If the name and message aren't empty
if (!empty($name) && !empty($msg)) {
// Email them to ourselves
mail("[email protected]", "Website Email", "{$name} says: {$msg}");
} else { // If they are empty
// Set an error message
$errors = "Please fill out the form.";
}
// If we have errors as this point, show them
if ($errors) print "<p>".$errors."</p>";
}
?>
<form method="post">
<p>Name: <input type="text" name="username" /></p>
<p>Message: <textarea name="message"></textarea></p>
<p><input type="submit" name="submit" /></p>
</form>
1
德看看http://swiftmailer.org/,使用mail()函数没有正确的数据转义可能是攻击和自定义页眉注射非常脆弱。
相关问题
- 1. 背景电子邮件发送在离子cordova申请
- 2. 申请表格电子邮件模板
- 3. PHP发送电子邮件多次发送电子邮件
- 4. PHP发送电子邮件
- 5. PHP发送电子邮件
- 6. PHP发送电子邮件
- 7. PHP的电子邮件表格不发送电子邮件
- 8. 如何申请“发送电子邮件为你”范围?
- 9. 在春季申请中发送预定电子邮件?
- 10. php表单不发送电子邮件
- 11. 用PHP邮件发送电子邮件()
- 12. PHP邮件不发送电子邮件
- 13. Php申请表 - 独特的电子邮件错误
- 14. 用HTML表单和PHP脚本发送邀请电子邮件
- 15. PHP发送电子邮件与文件附件 - 电子邮件不发送
- 16. Outlook的电子邮件报告申请
- 17. 提醒申请人的电子邮件
- 18. 电子邮件与PHP不发送电子邮件
- 19. smtp php电子邮件脚本不发送电子邮件
- 20. PHP电子邮件不发送电子邮件
- 21. PHP电子邮件结合字段发送电子邮件
- 22. 发送电子邮件在PHP - 空白电子邮件接收
- 23. PHP电子邮件脚本不发送电子邮件
- 24. PHP的形式不电子邮件发送电子邮件
- 25. Php电子邮件脚本不发送电子邮件
- 26. PHP电子邮件脚本不发送电子邮件
- 27. Flex&PHP - 发送电子邮件附件
- 28. php发送电子邮件附件
- 29. PHP电子邮件PDF附件发送
- 30. 发送PHP确认电子邮件管理员电子邮件发送