I'm running fedora core 9 with php 5.2.6. I want to send a simple email from a form using the php mail command.
Do I need to configure my system to be an smtp server? If so do I have to load something like pear?
I've read that pear is installed by default. however when I go to /usr/lib/php/pear , the folder is empty.
When I go to install pear with yum install php-pear none of the mirrors are available.
Does anyone have any suggesions on what mail service to use? If it's installed by default and where I can figure out how to configure.
Thanks! Joe
This the code I'm using:
<?php
require_once('../class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();
try {
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = "587"; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "joeiscool"; // GMAIL password
//This is the "Mail From:" field
$mail->SetFrom('[email protected]', 'First Last');
//This is the "Mail To:" field
$mail->AddAddress('[email protected]', 'John Doe');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->Send();
echo "Message Sent OK<p></p>\n";
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
?>