Hi fellows,
I am a PHP and online hosting noob, so sorry in advance for any obvious mistakes. I am trying to make a 'Contact Us' form on a new hosting service I signed up for.
So, I make a nice little html form with fields: Name, Email, Phone & Inquiry. Initially I tried using the normal mail() function of php to send the information to me, but the hosting service does not have the mail function enabled. Instead a PHP Mail with SMTP authentication is to be used.
The template given on the site is as:
require_once "Mail.php";
$from = "You ";
$to = "Recipient ";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";
$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("
" . $mail->getMessage() . "
");
} else {
echo("
Message successfully sent!
");
}
However, when I try to execute the code, I get:
Warning: Mail_smtp::include_once(Net/SMTP.php) [mail-smtp.include-once]: failed to open stream: No such file or directory in /usr/local/lib/php/Mail/smtp.php on line 206
Warning: Mail_smtp::include_once() [function.include]: Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /usr/local/lib/php/Mail/smtp.php on line 206
Fatal error: Class 'Net_SMTP' not found in /usr/local/lib/php/Mail/smtp.php on line 210
Anybody has any idea of what I might be doing wrong? Also, this php file is lying in my public directory, with username and password in it - wouldn't this be a security problem?