Created
November 14, 2013 16:04
-
-
Save hmkz/7469360 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* 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のアドレス | |
'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