Page 1 of 1

Trying PEAR mail working with backend PHP mail() [Answered]

PostPosted: 19. September 2012 17:53
by georgefk
Good afternoon. I can successfully send SMTP mail which is most important. I would like to know why it doesn't work using the PHP mail() function.
Let us limit the discussion to Win7/xampp1.8.0 although it seems to be the case with Vista/xampp1.7.7 too.
I have taken this PHP script from tuxradar. It is the most basic example. Just add FROM and TO email addresses and place in the document root.


Code: Select all
<?php
    include('Mail.php');
    $mail = Mail::factory("mail");

    $headers = array("From"=>"FROM_EMAIL_ADDRESS", "Subject"=>"Test Mail");
    $body = "This is a test!";
    $mail->send("TO_EMAIL_ADDRESS", $headers, $body);
?>


You will get Strict Standards error messages but these are not fatal and cannot explain the script's failure to send.
Does this happen to you?
If so, why is this the case?
best wishes
georgefk

Re: Trying to get PEAR mail working with backend PHP mail()

PostPosted: 21. September 2012 01:05
by JonB
how did you configure [mail function] in php.ini?

I'm also a bit lost on your parameter passes - "FROM_EMAIL_ADDRESS", "TO_EMAIL_ADDRESS"

:?:

But I'm not really an expert on that.

Edited - OK I feel better

Code: Select all
<?php
     include('Mail.php');
     $mail = Mail::factory("mail");

     $headers = array("From"=>"me@example.com", "Subject"=>"Test Mail");
     $body = "This is a test!";
     $mail->send("best@friend.com", $headers, $body);
?>


"that" I get...

So we are back to my original question (and) did you look in mailoutput?

8)

Re: Trying to get PEAR mail working with backend PHP mail()

PostPosted: 21. September 2012 15:00
by georgefk
I had not edited the default php.ini

Indeed the mails are sent and go to mailoutput.

I tried to edit php.ini so that the mails are sent to my mailbox. So far no success.
But that has greatly narrowed down my problem.

Thanks JonB!

Re: Trying PEAR mail working with backend PHP mail() [Answer

PostPosted: 22. September 2012 16:09
by georgefk
Need to set up SMTP in php.ini
Choose sendmail_path to send to a mailbox.

Finally set SMTP server in sendmail.ini

It will all work nicely.