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

Problems with the Windows version of XAMPP, questions, comments, and anything related.

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

Postby georgefk » 19. September 2012 17:53

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
georgefk
 
Posts: 12
Joined: 01. September 2012 16:03
XAMPP Version: 5.6.3
Operating System: Windows 7 Pro

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

Postby JonB » 21. September 2012 01:05

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)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
XAMPP Version: 1.8.3-2
Operating System: Windows XP/7 - Fedora 15 1.7.7

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

Postby georgefk » 21. September 2012 15:00

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!
georgefk
 
Posts: 12
Joined: 01. September 2012 16:03
XAMPP Version: 5.6.3
Operating System: Windows 7 Pro

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

Postby georgefk » 22. September 2012 16:09

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.
georgefk
 
Posts: 12
Joined: 01. September 2012 16:03
XAMPP Version: 5.6.3
Operating System: Windows 7 Pro


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 59 guests