I want to send email by using Gmail. For this, I just run the following command
pear install Mail Mail_Mime
My php file (filename.php) code is given below
<?php
require_once "Mail.php";
$from = 'from@gmail.com';
$to = 'to@gmail.com';
$subject = 'Hi!';
$body = "Hi,\n\nHow are you?";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'from@gmail.com',
'password' => 'password'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
?>
When I run this "filename.php" by using below command
php filename.php
I got the following Error
PHP Warning: include_once(Net/SMTP.php): failed to open stream: No such file or directory in /usr/share/pear/Mail/smtp.php on line 365
PHP Warning: include_once(): Failed opening 'Net/SMTP.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /usr/share/pear/Mail/smtp.php on line 365
PHP Fatal error: Class 'Net_SMTP' not found in /usr/share/pear/Mail/smtp.php on line 366
I am using CentOS 7.