MAMP 上的 php 邮件 [英] php mail on MAMP

查看:26
本文介绍了MAMP 上的 php 邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 PHP 的邮件测试一些脚本.我希望能够最终在本地完成这项工作.我正在使用 MAMP.有没有办法在不安装任何第三方软件的情况下做到这一点?

I need to test some script using PHP's mail. I'd like to be able to finally get this working locally. I am using MAMP. Is there a way to do this without installing any third party software?

我对此进行了一些搜索,但没有发现任何吸引人的地方.

I've done some searching on this but haven't found anything appealing.

谢谢

推荐答案

您是专门尝试测试邮件的发送,还是测试其余的代码?

Are you specifically trying to test the sending of mail, or are you testing the rest of the code?

如果是前者,则需要配置:

In the case of the former, you need to configure:

 SMTP = smtp.example.com
 smtp_port = 25
 sendmail_from = me@example.com

在您的 php.ini 文件中(使用 phpinfo() 检查它的位置),替换为适当的值.

in your php.ini file (check where it is with phpinfo()), substituting in appropriate values.

要测试发送邮件过程以外的代码,那么我建议创建 2 个包含文件:

To test the code other than the process of sending mail, then I'd recommend creating 2 include files:

<?php
// for live usage/mail send testing
function ori_mail()
{
   return call_user_func_array('mail',func_get_args());
}

以及用于测试其他代码

and for testing other code

function ori_mail()
{
   file_put_contents('debug_mail_scripts.txt'
       ,date('r') . ':' . var_export(func_get_args(), true)
       , FILE_APPEND);
}

并在您的测试中包含相关的内容.

And include the relevant one to your testing.

请注意,测试与 SMTP 服务器的集成以及测试代码的可交付性相当复杂,但应该独立于测试 PHP 完成.

Note that testing integration with the SMTP server, and testing deliverbility of your code is rather complex but should be done independently of testing your PHP.

C.

这篇关于MAMP 上的 php 邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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