I host my site with GoDaddy , and I use the PHP mail()
function at the moment to send form mails from my site. GoDaddy has a 1000 SMTP relay limit per day for form mail stuff, but they swear that with my PHP script that I should not be touching it.
我用GoDaddy托管我的网站,我现在使用PHP mail()函数从我的网站发送表单邮件。 GoDaddy每天为表单邮件提供1000个SMTP中继限制,但是他们发誓我的PHP脚本不应该触及它。
-
Since
mail()
doesn't take SMTP info, does it just automatically use GoDaddy's (or whatever hosting you may be on)?由于mail()不接受SMTP信息,它是否只是自动使用GoDaddy(或您可能在的任何主机)?
-
If my site is going to be expecting more than 1000 emails sent out a day (separate instances, not in a loop), should I be using a different method, or is
mail()
the right choice?如果我的网站预计每天发送超过1000封电子邮件(单独的实例,而不是循环),我应该使用不同的方法,还是mail()是正确的选择?
8 个解决方案
#1
Php uses by default, the local mail-server. However you can specify this in your php.ini configuration file.
Php默认使用本地邮件服务器。但是,您可以在php.ini配置文件中指定它。
If you expect to send more email than that, you might want to look into finding a different server to mail from, or alternative hosting
如果您希望发送更多的电子邮件,您可能希望寻找一个不同的服务器来发送邮件或替代托管
#2
Dont use mail() function of php it will send your mail to junk only. Instead use SMTP php mailer function.
不要使用php的mail()函数,它会将你的邮件发送到垃圾邮件。而是使用SMTP php邮件程序功能。
Why we should use SMTP instead PHP mail():
为什么我们应该使用SMTP代替PHP mail():
SMTP log in to an actual account on a mailserver and send the mail through SMTP to another mail server. If the mail server is configured correctly, your mails are sent from an actual account on a mailserver and will not wind up flagged as spam.
SMTP登录到邮件服务器上的实际帐户,并通过SMTP将邮件发送到另一个邮件服务器。如果邮件服务器配置正确,您的邮件将从邮件服务器上的实际帐户发送,并且不会被标记为垃圾邮件。
Mail sent with the mail() function is sent with sendmail in most cases. There is no authentication going on and it will almost always be flagged as spam if you use the "From:" in the extra headers.
在大多数情况下,使用sendmail发送带有mail()函数的邮件。没有进行身份验证,如果您在额外标头中使用“发件人:”,它几乎总是被标记为垃圾邮件。
This is because if you take a look at an original email file in say, gmail, you will see the headers that are sent. You are actually sending from user@serverhostname.tld and not someone@example.com like you had told the mail function to do. If you use SMTP and view the original the email is actually sent from someone@example.com
这是因为如果你看一下gmail中的原始电子邮件文件,你会看到发送的标题。您实际上是从user@serverhostname.tld发送的,而不是像您告诉邮件功能那样的someone@example.com。如果您使用SMTP并查看原始邮件,则电子邮件实际上是从someone@example.com发送的
You can download SMTP class from:
您可以从以下位置下载SMTP类:
#3
On a *nix machine, the PHP mail()
function does not support SMTP, but instead uses the sendmail() or other configured mail script on the server. This script can send through an SMTP, but this isn't the easiest way within PHP (unless you already have the script). To use SMTP, I would recommend PHPMailer. I have been using it for a few years now and have been impressed. It supports SMTP along with many other protocols and also has other helpful functionality, such as adding a text only body for an HTML email and creating the proper email headers. You can also extend the class to set defaults, such as the SMTP server and from email/name so you don't have to set these every time you want to send an email. It also does very nice error reporting and debugging.
在* nix机器上,PHP mail()函数不支持SMTP,而是使用服务器上的sendmail()或其他配置的邮件脚本。此脚本可以通过SMTP发送,但这不是PHP中最简单的方法(除非您已经拥有该脚本)。要使用SMTP,我建议使用PHPMailer。我已经使用它几年了,并留下了深刻的印象。它支持SMTP以及许多其他协议,还具有其他有用的功能,例如为HTML电子邮件添加纯文本正文以及创建正确的电子邮件标头。您还可以扩展类以设置默认值,例如SMTP服务器和电子邮件/名称,这样您就不必在每次发送电子邮件时都设置这些默认值。它还可以进行非常好的错误报告和调试。
I would also recommend this class for sending out 1000s of emails. I recently did >5000 in one day with it and had no problems.
我还建议这个课程发送1000多封电子邮件。我最近在一天内做了> 5000并且没有问题。
#4
If you need to use an external email server that requires authentication, you will not be able to use the PHP mail() function.
如果您需要使用需要身份验证的外部电子邮件服务器,您将无法使用PHP mail()函数。
I recommend using: http://pear.php.net/package/Mail
我建议使用:http://pear.php.net/package/Mail
#5
mail() does use the setting as defined in the php.ini. Windows servers require an actual smtp server while *nix servers will use whatever mta is installed on the server (if any).
mail()确实使用php.ini中定义的设置。 Windows服务器需要实际的smtp服务器,而* nix服务器将使用服务器上安装的任何mta(如果有)。
As others have mentioned, if you do want to use an alternate smtp server, use an alternative library like SwiftMailer. Also you'd want to make sure the smtp server is fast. I have seen slowdowns when using an smtp server like gmail.
正如其他人所提到的,如果你想使用备用的smtp服务器,请使用像SwiftMailer这样的替代库。此外,您还需要确保smtp服务器速度很快。我在使用像gmail这样的smtp服务器时看到了减速。
GoDaddy uses a Smart SMTP Relay, even on for dedicated servers hosted with GoDaddy. The limit is based on how many emails are going through the Smart relay.
GoDaddy使用智能SMTP中继,即使是使用GoDaddy托管的专用服务器也是如此。该限制基于通过智能中继的电子邮件数量。
If you have a valid reason for needing to send more emails and you can verify that your site isn't spamming and that all of the emails are opt-in, support will increase the limit for you if you give them an estimate of how many emails you need to send out.
如果您有正当理由需要发送更多电子邮件,并且您可以验证您的网站不是垃圾邮件并且所有电子邮件都是选择加入的,那么如果您给他们估计有多少电子邮件,支持会增加您的限制您需要发送的电子邮件。
#6
Since this is an old post I thought it would be helpful if I updated the answer -
由于这是一篇旧帖,我认为如果我更新答案会有帮助 -
This is a lot simpler to do now than it used to be :-) In PHP 4 the PEAR Mail package is typically already installed, and this really simple tutorial shows you the few lines of code that you need to add to your php file http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
这比现在要简单得多:-)在PHP 4中,PEAR Mail包通常已经安装,这个非常简单的教程向您展示了需要添加到php文件中的几行代码http ://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
Most hosting companies list the SMTP settings that you'll need. I use JustHost, and they list theirs at https://my.justhost.com/cgi/help/26 (under Outgoing Mail Server)
大多数托管公司列出了您需要的SMTP设置。我使用JustHost,他们在https://my.justhost.com/cgi/help/26(在发送邮件服务器下)列出他们的内容
#7
If you need to use a third party mail service I'd recommend dropping the use of mail()
and replace with the SwiftMailer library. It's a feature rich component (supports authentication, attachments, encryption etc) we've used it in a few places. It's also free and open source.
如果您需要使用第三方邮件服务,我建议不要使用mail()并替换SwiftMailer库。它是一个功能丰富的组件(支持身份验证,附件,加密等),我们在一些地方使用过它。它也是免费和开源的。
#8
I've been using the open source project phpmailer for about seven years-- it is terrific! You could use it to connect to an offsite SMTP server.
我一直在使用开源项目phpmailer大约七年 - 这太棒了!您可以使用它来连接到非现场SMTP服务器。
#1
Php uses by default, the local mail-server. However you can specify this in your php.ini configuration file.
Php默认使用本地邮件服务器。但是,您可以在php.ini配置文件中指定它。
If you expect to send more email than that, you might want to look into finding a different server to mail from, or alternative hosting
如果您希望发送更多的电子邮件,您可能希望寻找一个不同的服务器来发送邮件或替代托管
#2
Dont use mail() function of php it will send your mail to junk only. Instead use SMTP php mailer function.
不要使用php的mail()函数,它会将你的邮件发送到垃圾邮件。而是使用SMTP php邮件程序功能。
Why we should use SMTP instead PHP mail():
为什么我们应该使用SMTP代替PHP mail():
SMTP log in to an actual account on a mailserver and send the mail through SMTP to another mail server. If the mail server is configured correctly, your mails are sent from an actual account on a mailserver and will not wind up flagged as spam.
SMTP登录到邮件服务器上的实际帐户,并通过SMTP将邮件发送到另一个邮件服务器。如果邮件服务器配置正确,您的邮件将从邮件服务器上的实际帐户发送,并且不会被标记为垃圾邮件。
Mail sent with the mail() function is sent with sendmail in most cases. There is no authentication going on and it will almost always be flagged as spam if you use the "From:" in the extra headers.
在大多数情况下,使用sendmail发送带有mail()函数的邮件。没有进行身份验证,如果您在额外标头中使用“发件人:”,它几乎总是被标记为垃圾邮件。
This is because if you take a look at an original email file in say, gmail, you will see the headers that are sent. You are actually sending from user@serverhostname.tld and not someone@example.com like you had told the mail function to do. If you use SMTP and view the original the email is actually sent from someone@example.com
这是因为如果你看一下gmail中的原始电子邮件文件,你会看到发送的标题。您实际上是从user@serverhostname.tld发送的,而不是像您告诉邮件功能那样的someone@example.com。如果您使用SMTP并查看原始邮件,则电子邮件实际上是从someone@example.com发送的
You can download SMTP class from:
您可以从以下位置下载SMTP类:
#3
On a *nix machine, the PHP mail()
function does not support SMTP, but instead uses the sendmail() or other configured mail script on the server. This script can send through an SMTP, but this isn't the easiest way within PHP (unless you already have the script). To use SMTP, I would recommend PHPMailer. I have been using it for a few years now and have been impressed. It supports SMTP along with many other protocols and also has other helpful functionality, such as adding a text only body for an HTML email and creating the proper email headers. You can also extend the class to set defaults, such as the SMTP server and from email/name so you don't have to set these every time you want to send an email. It also does very nice error reporting and debugging.
在* nix机器上,PHP mail()函数不支持SMTP,而是使用服务器上的sendmail()或其他配置的邮件脚本。此脚本可以通过SMTP发送,但这不是PHP中最简单的方法(除非您已经拥有该脚本)。要使用SMTP,我建议使用PHPMailer。我已经使用它几年了,并留下了深刻的印象。它支持SMTP以及许多其他协议,还具有其他有用的功能,例如为HTML电子邮件添加纯文本正文以及创建正确的电子邮件标头。您还可以扩展类以设置默认值,例如SMTP服务器和电子邮件/名称,这样您就不必在每次发送电子邮件时都设置这些默认值。它还可以进行非常好的错误报告和调试。
I would also recommend this class for sending out 1000s of emails. I recently did >5000 in one day with it and had no problems.
我还建议这个课程发送1000多封电子邮件。我最近在一天内做了> 5000并且没有问题。
#4
If you need to use an external email server that requires authentication, you will not be able to use the PHP mail() function.
如果您需要使用需要身份验证的外部电子邮件服务器,您将无法使用PHP mail()函数。
I recommend using: http://pear.php.net/package/Mail
我建议使用:http://pear.php.net/package/Mail
#5
mail() does use the setting as defined in the php.ini. Windows servers require an actual smtp server while *nix servers will use whatever mta is installed on the server (if any).
mail()确实使用php.ini中定义的设置。 Windows服务器需要实际的smtp服务器,而* nix服务器将使用服务器上安装的任何mta(如果有)。
As others have mentioned, if you do want to use an alternate smtp server, use an alternative library like SwiftMailer. Also you'd want to make sure the smtp server is fast. I have seen slowdowns when using an smtp server like gmail.
正如其他人所提到的,如果你想使用备用的smtp服务器,请使用像SwiftMailer这样的替代库。此外,您还需要确保smtp服务器速度很快。我在使用像gmail这样的smtp服务器时看到了减速。
GoDaddy uses a Smart SMTP Relay, even on for dedicated servers hosted with GoDaddy. The limit is based on how many emails are going through the Smart relay.
GoDaddy使用智能SMTP中继,即使是使用GoDaddy托管的专用服务器也是如此。该限制基于通过智能中继的电子邮件数量。
If you have a valid reason for needing to send more emails and you can verify that your site isn't spamming and that all of the emails are opt-in, support will increase the limit for you if you give them an estimate of how many emails you need to send out.
如果您有正当理由需要发送更多电子邮件,并且您可以验证您的网站不是垃圾邮件并且所有电子邮件都是选择加入的,那么如果您给他们估计有多少电子邮件,支持会增加您的限制您需要发送的电子邮件。
#6
Since this is an old post I thought it would be helpful if I updated the answer -
由于这是一篇旧帖,我认为如果我更新答案会有帮助 -
This is a lot simpler to do now than it used to be :-) In PHP 4 the PEAR Mail package is typically already installed, and this really simple tutorial shows you the few lines of code that you need to add to your php file http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
这比现在要简单得多:-)在PHP 4中,PEAR Mail包通常已经安装,这个非常简单的教程向您展示了需要添加到php文件中的几行代码http ://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
Most hosting companies list the SMTP settings that you'll need. I use JustHost, and they list theirs at https://my.justhost.com/cgi/help/26 (under Outgoing Mail Server)
大多数托管公司列出了您需要的SMTP设置。我使用JustHost,他们在https://my.justhost.com/cgi/help/26(在发送邮件服务器下)列出他们的内容
#7
If you need to use a third party mail service I'd recommend dropping the use of mail()
and replace with the SwiftMailer library. It's a feature rich component (supports authentication, attachments, encryption etc) we've used it in a few places. It's also free and open source.
如果您需要使用第三方邮件服务,我建议不要使用mail()并替换SwiftMailer库。它是一个功能丰富的组件(支持身份验证,附件,加密等),我们在一些地方使用过它。它也是免费和开源的。
#8
I've been using the open source project phpmailer for about seven years-- it is terrific! You could use it to connect to an offsite SMTP server.
我一直在使用开源项目phpmailer大约七年 - 这太棒了!您可以使用它来连接到非现场SMTP服务器。