PHP mail () function has stopped working

I am developing a web application with the MAMP solution package (v2.0.5) which includes:

  • Mac OS X (v10.7.3)
  • Apache v2.2.21
  • MySQL v5.5.9
  • PHP v5.3.6

I am using a PHP function mail()

to send the activation url to the newly registered user accounts:

$body = "Thank you for registering. To active your account, please click on this link:\n\n";
$body .= BASE_URL . 'activate.php?x=' . urlencode($e) . "&y=$a" . "&z=$bs";
mail($trimmed['email'], 'Registration Confirmation', $body, 'From: admin@tester.com');

      

However, it looks like after a while ... it just stopped and now I am not getting any of these messages in the tester's user accounts.

My file php.ini

is located at: /Applications/MAMP/bin/php/php5.3.6/conf/php.ini

With default settings:

[mail function]
; For Win32 only.
SMTP = localhost
smtp_port = 25

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

      

It used to work fine until recently and has now failed. I didn’t intentionally change any of the settings I’m aware of, it might have stopped this.

After a lot of talking and reading, it seems like you need to configure your SMTP server to send emails from your localhost to another email address for it to work at all, but I'm pretty sure it did work, I got emails ... honestly!

Hope someone can help. Many thanks.

UPDATED-RESOLVE: Mostly sorted. Began trying to use PEAR and the Mail plugin but found it terrible. Ends up using an external SMTP server and PHPMailer is much better.

Useful info: http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html https://orangsetya.wordpress.com/2007/09/12/send-mail-using-smtp- authentication-phpmailer-script

+3


source to share


2 answers


Mostly sorted. Began trying to use PEAR and the Mail plugin but found it terrible. Ends up using an external SMTP server and PHPMailer is much better.

Useful info: http://www.askapache.com/php/phpfreaks-eric-rosebrocks-phpmailer-tutorial.html https://orangsetya.wordpress.com/2007/09/12/send-mail-using- SMTP- authentication-phpmailer-script



Greetings.

+1


source


Create a new script with the mail command and enter the code as strings to see if you receive emails. Also check if any updates to your OS have made any changes to your apache / php installation.

Try a simple script like this:



<?php
    mail('youremail@example.com', 'My Subject', 'My Message');
?>

      

+2


source







All Articles