Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

email - php mail on 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.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 = [email protected]

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...