如何从 php 文件发送电子邮件?
我知道php中的邮件功能: mail ($to, $subject, $msg_body,$headers);
但由于我无法访问主机的 php.ini 文件,因此我获得了以下详细信息:
SMTP host: mailout.host.com
Port: 25 SMTP
Username: [email protected]
SMTP Password: not required
Authentication: Disabled
Encryption: Disabled
如何使用这些详细信息发送电子邮件?
编辑:我使用了 Blender 指出的示例(如下),它似乎适用于除 gmail 之外的所有电子邮件。知道为什么吗?这与完全合格的地址有关吗?
I know about the mail function in php:mail ($to, $subject, $msg_body,$headers);
But since I cannot access my host's php.ini file, I've been provided with the following details:
SMTP host: mailout.host.com
Port: 25 SMTP
Username: [email protected]
SMTP Password: not required
Authentication: Disabled
Encryption: Disabled
How can I use these details to send out emails?
EDIT: I used example pointed by Blender (below) and it seems to work fine for all emails except gmail. Any idea why? Is it to do with Fully Qualified Address?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PHPMailer 是一个非常知名且广泛使用的替代方案
查看SMTP 邮件示例
PHPMailer is a very well known and widely used alternative
Check out the SMTP mail example
您可以使用 SwiftMailer (http://swiftmailer.org/) 通过您可以登录的任何电子邮件帐户(包括 gmail)发送电子邮件。它非常强大,但确实有一个错误,即它会为包含大量 html 的电子邮件使用大量内存。
You can use SwiftMailer (http://swiftmailer.org/) to send out emails through any email account you can login to, including gmail. It's very robust, but does have a bug where it uses a lot of memory for emails that have a lot of html in them.