The first, please download pear library here
http://pear.php.net/
and then extract file and rename tobe "Pear_lib"
create file send_mail.php
<?php
// Pear Mail Library
require_once "Pear_lib/Mail.php";
$from = '<user@gmail.com>';
$to = '<user@yahoo.co.id>';
$subject = 'Hi!';
$body = "<html>Testing Email,<br>Test </html>";
$headers = array(
'From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html; charset=UTF-8'
);
$smtp = Mail::factory('smtp', array(
'host' => 'ssl://smtp.gmail.com',
'port' => '465',
'auth' => true,
'username' => 'user@gmail.com',
'password' => 'xxxxxxxxx'
));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo('<p>' . $mail->getMessage() . '</p>');
} else {
echo('<p>Message successfully sent!</p>');
}
?>
No comments:
Post a Comment