
August 9th, 2007, 02:15 AM
|
|
Contributing User
|
|
Join Date: Jul 2007
Posts: 44
Time spent in forums: 18 h 34 m 24 sec
Reputation Power: 3
|
|
|
Smtp pear mail problem
Hi! I tried the below code on my website but could not figure out how to make it work.
PHP Code:
<?php
require_once "Mail.php";
$from = "My Name <info@mydomain.com>";
$to = "Customer <customer@gmail.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.mydomain.com";
$username = "info@mydomain.com";
$password = "mypass";
$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>");
}
?>
It produce this error->
Warning: main(Mail.php) [function.main]: failed to open stream: No such file or directory in /home/username/public_html/testmail.php on line 2
Fatal error: main() [function.require]: Failed opening required 'Mail.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/username/public_html/testmail.php on line 2
Since I just saw the code on some website, I have no idea what is the content of Mail.php file and it is not existing on my root folder. Please advise on how I can make it work so I can start sending emails. Thank you.
|