PHPMailer诉mail()获得简单的联系表 [英] PHPMailer v. mail() for a simple Contact Form
问题描述
我是PHP的新手,但是对事物有一定的了解(还没有学习过类).
I am new to PHP, but have a decent grasp of things (have not learned classes yet).
问题:
选择哪个? PHPMailer或mail()作为我的新联系表.
Which to choose? PHPMailer or mail() for my new contact form.
表格很简单:
Your name:
Your email:
Subject:
Body:
我每天大约有2,000位访问者,每天大约收到10份提交内容,因此我不需要花哨的东西. =)
I have around 2,000 visitors per day and receive about 10 submissions per day, so I don't need anything too fancy. =)
我脑海中的其他问题:
- PHPMailer会更好地保护我的联系表单免受CC:注入(主要关注)吗?我已经知道
anti-spambot display:none CSS
技巧. - PHPMailer可以为我省去编写
email_validator()
函数的步骤吗? - PHPMailer会为我省去编写其他自定义函数的任何其他时间吗?
- Is PHPMailer going to better protect my Contact Form from CC: injection (major concern)? I already know the
anti-spambot display:none CSS
trick. - Will PHPMailer save me the step of having to write an
email_validator()
function? - Will PHPMailer save me any other time of having to write any custom functions?
谢谢!运气好的话,我会尽快回答问题.哈哈
Thanks! With any luck, I'll be answering questions soon. Lol
推荐答案
在这里,我能一口气想到的一切,如果有任何明显的遗漏,请原谅我.
Here is all I could think of in one sitting, forgive me if there are any glaring omissions.
使用PHP的内置邮件功能的优势,无需外部库/包装器:
Advantages to using PHP's built-in mail function, no external library/wrapper:
- 您不需要任何其他东西 PHP.
- 您不需要学习新的API.
- 您不必担心PHP 升级或破坏脚本.
- 您不必担心 更新的版本不适用于您的 PHP安装.
- 您不必担心 潜在的安全漏洞为 使用该脚本的结果.
- 如果这是一项简单的任务,您将可以完成 几分钟后.
- You don't need anything outside of PHP.
- You don't need to learn a new API.
- You don't have to worry about a PHP upgrade or such breaking the script.
- You don't have to worry about an updated version not working on your PHP installation.
- You don't have to worry about potential security vulnerabilities as a result of using that script.
- If it's a simple task, you'll be done in a few minutes.
使用外部库/包装的优势:
Advantages to using an external library/wrapper:
- 如果您需要介绍更多
电子邮件的复杂性,
可以很容易地做到这一点.新增中
附件,内嵌图片等
使用PHP纯邮件的乐趣并不多
功能.外部库(位于
至少是好的)有更多
OOPish API.添加附件可以像
$message->addAttachment($file);
一样简单,而无需使用标题等. - 外部库可以更好地隐藏 诸如此类的任务的丑陋复杂性 添加附件,字符 编码和内嵌图片.
- 立即使用图书馆可为您节省 麻烦必须在 将来要做时需要 额外的复杂性/功能.
- 外部库可能(我是 真的不确定那些 在多大程度上)解决某些问题 PHP邮件确实存在的漏洞 不是.
- If you need to introduce more
complexity into your emailing, you
can do so quite easily. Adding
attachments, inline images and such
are not much fun using PHP plain mail
function. External libraries (at
least the good ones) have a more
OOPish API. Adding an attachment can be as easy as
$message->addAttachment($file);
without having to play around with headers, etc. - External libraries better hide the ugly complexities of tasks such as adding attachments, character encodings and inline images.
- Using a library now will save you the hassle of having to learn it in the future when you do need the additional complexity/functionality.
- External libraries probably (I'm really not sure which ones, and to what extent) address certain vulnerabilities that PHP's mail does not.
如果我能想到其他任何事情,请确保将其添加.
If I can think of anything else, I'll be sure to add it.
这篇关于PHPMailer诉mail()获得简单的联系表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!