使用MAMP和PHP脚本发送电子邮件

编程入门 行业动态 更新时间:2024-10-09 06:26:37
本文介绍了使用MAMP和PHP脚本发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在mac上运行MAMP到本地主机一个网站。我想使用php脚本发送电子邮件。我在网上看的东西告诉我关于电子邮件的php脚本,但我无法发送电子邮件。我猜这是与MAMP设置有关,也许我必须对php.ini文件进行更改,但我无法找到相关信息。我可以使用我的运行php脚本的gmail地址向我的客户端发送电子邮件。我正在创建一个注册页面,一旦您成功注册,该网站会给您一个欢迎的电子邮件。一些身体可以指导我如何做到这一点。我使用了这里的代码: http://email.about。 com / od / emailprogrammingtips / qt / PHP_Email_SMTP_Authentication.htm 但是这不行。 我已经使用以下设置: $ host =ssl://smtp.gmail; $ port =465;

解决方案

MAMP只是Apache,MySQL和PHP,不包括邮件服务器。您可以使用 postfix 或正如您所说的外部SMTP服务器。

如果使用Gmail,请确保您的帐户已设置为允许SMTP连接(默认情况下关闭)。这可以在Web客户端的设置中找到。我建议您使用邮件或本地机器上的其他邮件客户端进行测试,以确保Gmail正常运行。

最后(一旦设置了上述) SwiftMailer 或 PHPMailer 是可以连接到远程SMTP服务器的好邮件库。这将节省您编写自己的代码的许多头痛,特别是当涉及文件附件等时。

Hi I am running MAMP on my mac to locally host a website. I want to send an email using php scripts. The stuff i looked online tells me about php scripts for emails but i am unable to send emails. I am guessing this has to do with MAMP settings or maybe i have to make changes to php.ini file but i cant find information regarding that. Can i send emails to my clients using my gmail address running php scripts. I am creating a signup page where once you signup successfully, the site sents you a welcome email. Can some body please guide me how to do this. I have used code from here: email.about/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm but this doesnt work. i have used following settings: $host = "ssl://smtp.gmail"; $port = "465";

解决方案

MAMP is just Apache, MySQL and PHP and doesn't include a mail server. You could use postfix or, as you said, an external SMTP server.

If using Gmail make sure your account is setup to allow SMTP connections (it's off by default). This can be found somewhere in Settings in the web client. I'd recommend you test it with Mail or another mail client on your local machine to make sure Gmail is working as expected.

Finally (once the above is set up) SwiftMailer or PHPMailer are good mail libraries which can connect to remote SMTP servers. It'll save you a lot of headaches writing your own code, especially when it comes to file attachments and such.

更多推荐

使用MAMP和PHP脚本发送电子邮件

本文发布于:2023-10-12 16:17:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1485250.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   发送电子邮件   MAMP   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!