使用MAMP和PHP脚本发送电子邮件 [英] sending an email using MAMP and php scripts

查看:137
本文介绍了使用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.com;
$ 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: http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm but this doesnt work. i have used following settings: $host = "ssl://smtp.gmail.com"; $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脚本发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆