Skip to content

Instantly share code, notes, and snippets.

@karthikeyann
Forked from hmkz/sendMailViaGmail.php
Last active August 29, 2015 13:56
Show Gist options
  • Save karthikeyann/9006263 to your computer and use it in GitHub Desktop.
Save karthikeyann/9006263 to your computer and use it in GitHub Desktop.
Send mail via your gmail account to anyone.
<?php
// NOTE: Make this file not readable to others.
/**
* Gmail
* Pear::Mail
* @param string $to
* @param string $from
* @param string $bcc BCC
* @param string $subj
* @param string $body
* @return bool true
*/
function sendMailViaGmail($to, $from, $bcc, $subj, $body) {
require_once "Mail.php";
$params = array(
'host' => 'smtp.gmail.com',
'port' => 587,
'auth' => true,
'debug' => false,
'username' => '[email protected]', //gmail username
'password' => 'xxxx' //gmail password
);
$headers = array(
'To' => $to,
'From' => $from,
'Bcc' => $bcc,
'Subject' => $subj
);
$smtp = Mail::factory("smtp", $params);
$ret = $smtp->send($to, $headers, $body);
return $ret;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment