Skip to content

Instantly share code, notes, and snippets.

@hidayat365
Created April 30, 2012 03:42
Show Gist options
  • Save hidayat365/2555249 to your computer and use it in GitHub Desktop.
Save hidayat365/2555249 to your computer and use it in GitHub Desktop.
Emailing using PEAR Mail
<?php
// require PEAR:Mail
require_once("Mail.php");
// parameter mail
$host = "ssl://smtp.google.com";
$port = 465;
$email = "your_account@gmail.com";
$pass = "your_gmail_password";
// buat instance mailer
$smtp = Mail::factory('smtp',
array ( 'host' => $host,
'port' => $port,
'auth' => true,
'username' => $email,
'password' => $pass ) );
// parameter pngiriman email
$to = 'aaa@gmail.com';
$cc = 'bbb@gmail.com';
$from = 'your_account@gmail.com';
$headers = array (
'From' => $from,
'To' => $to,
'Cc' => $cc,
'Reply-To' => $from,
'Date' => date(DATE_RFC822),
'Subject' => $subject,
'X-Mailer' => 'PHP/'.phpversion(),
'MIME-Version' => '1.0',
'Content-type' => "text/html; charset='utf-8'",
'Content-Transfer-Encoding' => '8bit'
);
$recipients = $to.','.$cc;
$message = 'your message here';
// kirimkan email
$mail = $smtp->send($recipients, $headers, $message);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment