Created
April 30, 2012 03:42
-
-
Save hidayat365/2555249 to your computer and use it in GitHub Desktop.
Emailing using PEAR Mail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// require PEAR:Mail | |
require_once("Mail.php"); | |
// parameter mail | |
$host = "ssl://smtp.google.com"; | |
$port = 465; | |
$email = "[email protected]"; | |
$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 = '[email protected]'; | |
$cc = '[email protected]'; | |
$from = '[email protected]'; | |
$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