Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 600
Ori Avatar asked Aug 04 '09 08:08

Ori


People also ask

How to send mail from localhost in php using MAMP?

We can send mail from our localhost using some mail configuration by XAMPP/LAMP/WAMP server, First we need to enable php_openssl php extensions from php. ini file. I am using GMAIL SMTP server to send mail from localhost and sendmail package,It is a mail transport agent which can be found in php. ini file.

What mail server does php mail use?

Php uses by default, the local mail-server.

Does Mamp have php?

PHP is a popular web scripting programming language. MAMP PRO installs several versions of the PHP script interpreter. button. Note: To remove unneeded PHP versions simply stop your servers, quit MAMP PRO, and remove your /Applications/MAMP/bin/php/phpX.

What does Mamp Pro do?

MAMP Pro allows you to store your files in the cloud via Dropbox or OneDrive. You can store one, or all of your hosts in the cloud. This is a great way to protect you from accidentally deleting files on your projects, and allows you to work on sites on different computers.


1 Answers

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.

like image 120
symcbean Avatar answered Sep 18 '22 20:09

symcbean