Created
May 8, 2017 13:32
-
-
Save katsuobushiFPGA/e86ab2fb0b24963d43328d798fd6b619 to your computer and use it in GitHub Desktop.
This file contains 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 | |
date_default_timezone_set("Asia/Tokyo"); | |
error_reporting(E_ALL); | |
header( "Content-Type: text/html; Charset=utf-8" ); | |
header( "pragma: no-cache" ); | |
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" ); | |
header( "Cache-control: no-cache" ); | |
require_once("Mail.php"); | |
mb_language("ja"); | |
mb_internal_encoding("UTF-8"); | |
// *********************************************** | |
// 通信のデバッグ表示 | |
// *********************************************** | |
$debug = true; | |
// *********************************************** | |
// SMTP 接続設定 | |
// *********************************************** | |
$settings = array( | |
"host" => "ssl://smtp-mail.outlook.com", | |
"port" => "587", | |
"auth" => true, | |
"username" => "", | |
"password" => "", | |
"debug" => $debug | |
); | |
// *********************************************** | |
// メールアドレス | |
// *********************************************** | |
$to_address = ""; | |
$from_address = ""; | |
// *********************************************** | |
// メールヘッダー | |
// *********************************************** | |
$subject = "Gmail(SSL/465)を使ってPHPでメールを送る"; | |
$subject = mb_encode_mimeheader( mb_convert_encoding($subject,"iso-2022-jp") ); | |
$to_header = mb_encode_mimeheader( mb_convert_encoding("宛先","iso-2022-jp") ) . " <{$to_address}>"; | |
$from_header = mb_encode_mimeheader( mb_convert_encoding("差出人","iso-2022-jp") ) . " <{$from_address}>"; | |
$headers = array( | |
"To" => $to_header, | |
"From" => $from_header, | |
"Subject" => $subject | |
); | |
// *********************************************** | |
// 本文 | |
// *********************************************** | |
$body="本文"; | |
$body = mb_convert_encoding($body,"iso-2022-jp"); | |
// *********************************************** | |
// SMTP 接続設定をオブジェクトに設定 | |
// *********************************************** | |
$smtp = Mail::factory("smtp", $settings); | |
// *********************************************** | |
// 送信 | |
// *********************************************** | |
print "<pre>"; | |
$result = $smtp->send( | |
$to_address, | |
$headers, | |
$body ); | |
print "</pre>"; | |
if ( PEAR::isError($result) ) { | |
error_log("[" .date("Y/m/d/H:m:s") . "]" . $result->getMessage() . "\n", 3, 'send_mail_error.log'); | |
print "メール送信エラー:" . $result->getMessage(); | |
} | |
?> | |
OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment