Jump to content

"Undefined Class Name" error??


Michael4172

Recommended Posts

I'm attempting to use the following piece of code that I've downloaded from the web. However when I run the script it gives me a "Fatal error: Undefined class name 'mail' on line 15'. Any ideas?

[code]
<?php
require_once "test.php";

$from = "<[email protected]>";
$to = "<[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "abc.abc.net";
$username = "[email protected]";
$password = "abc";

$headers = array ('From' => $from,'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/12144-undefined-class-name-error/
Share on other sites

Heres a mail sender that allows you to use html in it good luck


[code]
<?php
// multiple recipients
$to  = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
  <title>Birthday Reminders for August</title>
</head>
<body>
  <p>Here are the birthdays upcoming in August!</p>
  <table>
   <tr>
     <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
   </tr>
   <tr>
     <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
   </tr>
   <tr>
     <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
   </tr>
  </table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>
[/code]
[code]
<?php

@set_time_limit(0);

require_once 'smtp_mail.php';

$to = "[email protected]";
$from = "[email protected]";
$subject = "Subject here";

$headers = "MIME-Version: 1.0\r\n".
   "Content-type: text/html; charset=iso-8859-1\r\n".
   "From: \"My Name\" <".$from.">\r\n".
   "To: \"Client\" <".$to.">\r\n".
   "Date: ".date("r")."\r\n".
   "Subject: ".$subject."\r\n";

$message = "
<html>
<body>
<b>html message</b><br>
<font color=\"red\">here</font>
<img src=\"http://static.php.net/www.php.net/images/php.gif\"
border=\"0\" alt=\"\">
</body>
</html>
";

$response = smtp_mail($to, $subject, $message, $from, $headers);

if($response[0]) echo "The message has been sent !<br />\n".$response[1];
else echo "The message can not been sent !<br />\n".$response[1];

[/code]

[code]
<?php
require_once "test.php";

$from = "<[email protected]>";
$to = "<[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

$host = "abc.abc.net";
$username = "[email protected]";
$password = "abc";

$headers = array ('From' => $from,'To' => $to,
  'Subject' => $subject);

$smtp = array ('smtp',array ('host' => $host,'auth' => true,'username' => $username,'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
?>

[/code]

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.