Hi All,
I'm in the process of learning PHP and I don't know everything so please bare with me. I'm trying to have a simple e-mail script which will send a nice e-mails with variables from a previous form. I don't want to use my PHP servers predefined e-mail settings but define them myself. I plan on using G-Mail's SSL SMTP protocol. Upon looking up scripts for e-mailing I'm always coming across
require_once "Mail.php";
in the code with no explanation on where that file is located. I'm currently using this code for to see if it works:
<?php
require_once "Mail.php";
$from = "Sandra Sender <
[email protected]>";
$to = "Ramona Recipient <
[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "ssl://mail.example.com";
$port = "465";
$username = "smtp_username";
$password = "smtp_password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'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>");
}
But I get the error
Fatal error: Class 'Mail' not found in C:\wamp\www\Quiz\sendmail.php on line 16
If anyone could be so kind to give me an explanation and assist me in understanding, that'd be great.
Thanks,
Evan