freakythumbs Posted December 10, 2007 Share Posted December 10, 2007 Well I feel like ive turned every stone & its still not working and I cant see why, especially since I have a PHP package (moodle) that is emailing fine i have installed the PEAR packages mail & mail_mime and still no joy im just trying to create a basic page that sends an email but i test the code below it gives me an internal server error. any ideas? thanks <?php require "Mail.php"; require "Mail/mime.php"; $from = "webmaster@test.co.nz"; $to="webmaster@test.co.nz"; $cc="webmaster@test.co.nz"; $subject="Sending e-mails from PEAR::Mail"; $headers=array('From'=>$from,'To'=>$to,'Cc'=>$cc,'Subject'=>$subject); $host = "smtp.domain.co.nz"; $username ="user"; $password ="password"; $smtp = Mail::factory('smtp',array('host'=>$host,'auth'=>true,'username'=>$username,'password'=>$password)); $mime=new Mail_mime(); $txtBody = <<< BODY Hello, This is a test email sent from the PEAR::Mail Class. BODY; $mime->setTXTBody($txtBody); $htmlBody=<<< BODY <html><body> <h1>Hello,</h1> This is a test email sent from the PEAR::Mail Class. </body></html> BODY; $mime->setHTMLBody($htmlBody); $body = $mime->get(); $headers=$mime->headers($headers); $mail=$smtp->send($to,$headers,$body); // test file to send an email direct from the server echo "Email sent successfully!"; ?> Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2007 Share Posted December 11, 2007 Can you send a simple email via the mail function? Quote Link to comment Share on other sites More sharing options...
freakythumbs Posted December 11, 2007 Author Share Posted December 11, 2007 i have but it didnt work either, thanks Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2007 Share Posted December 11, 2007 Then maybe your smtp server is misconfigured. Is this shared hosting? Or what? Quote Link to comment Share on other sites More sharing options...
freakythumbs Posted December 11, 2007 Author Share Posted December 11, 2007 it is a co-hosted server but CDONTS sends emails fine as does Moodle so it doesnt appear to have a problem using port 25 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.