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

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

问题描述

我需要使用PHP的邮件测试一些脚本。我希望能够在本地工作。我正在使用MAMP。有没有办法这样做,而不安装任何第三方软件?



我已经做了一些搜索,但没有发现任何有吸引力的。



谢谢

解决方案

你是否专门测试发送邮件,还是你测试其余代码?



在前者的情况下,您需要配置:

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

(使用phpinfo()检查它的位置),以适当的值替换。



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

 <?php 
//用于实际使用/邮件发送测试
函数ori_mail()
{
return call_user_func_array('mail',func_get_args());
}

和测试其他代码


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

并将相关的一个添加到您的测试中。



请注意,与SMTP服务器的测试集成以及测试代码的可执行性相当复杂,但应独立于测试您的PHP进行。



C。


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.

Thanks

解决方案

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

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

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.

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.

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

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