Forum Moderators: coopster

Message Too Old, No Replies

PHP Pear package mail

         

andrewsmd

7:43 pm on Dec 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am having trouble with the mail.php file that uses pear. I know that Pear and the mail.php files are installed correctly. Here is my code.

require_once("Mail.php");

$mail = Mail::factory("mail");

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

var_dump($mail);
echo("test");

here is the output I get so I know it's kind of working

object(Mail_mail)#1 (2) { ["_params"]=> string(0) "" ["sep"]=> string(2) " " } test
I am not an object oriented programmer so I don't really know what is going on but I am not getting an e-mail. My server in the php.ini file is localhost and there is no password or username for it. It is set to go out on port 25. Any help? Thanks,

coopster

3:00 pm on Dec 11, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Your sendmail binary on Unix needs to be properly configured to process the request. If this is on a Windows box, you need to have a properly configured and functioning SMTP server (and port) defined in your php.ini. Since you stated you have the server in the php.ini, I'll assume you are running on Windows. A neat trick in Windows, if you do not want to set up and run your SMTP server locally, is that you can define a different SMTP server in the php.ini, including your local ISP (as long as you don't have to authenticate). If you do have to authenticate, a quick trick is to leave an email client open and running on the machine that initiates the connection/authentication and your mail functions should work fine.

andrewsmd

4:55 pm on Dec 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know that we have an SMTP server running, I just didn't set it up. Do you have any other suggestions on how to make this work.