Jump to content

PHP emailing not working! Must be something simple...


freakythumbs

Recommended Posts

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 = "[email protected]";

$to="[email protected]";

$cc="[email protected]";

$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!";

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.