Skip to content

Instantly share code, notes, and snippets.

@hmkz
Created November 14, 2013 16:04
Show Gist options
  • Save hmkz/7469360 to your computer and use it in GitHub Desktop.
Save hmkz/7469360 to your computer and use it in GitHub Desktop.
<?php
/**
* 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' => 'xxx@gmail.com', // Gmailのアドレス
'password' => 'xxxx' // Gmailパスワード
);
$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