-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendmail.php
More file actions
29 lines (26 loc) · 1.09 KB
/
sendmail.php
File metadata and controls
29 lines (26 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
# メールを送信する関数です。
function sendmail($fromName, $from, $to, $subject, $body, $returnPath = null)
{
# メールアドレスや件名に改行コードが含まれないことをチェックします。
if (preg_match('/[\r\n]/', $fromName) !== 0
|| preg_match('/[\r\n]/', $from) !== 0
|| preg_match('/[\r\n]/', $to) !== 0
|| preg_match('/[\r\n]/', $subject) !== 0) {
die('不正な入力が検出されました。');
}
if (is_null($returnPath)) {
$returnPath = $from;
}
# Fromヘッダーを作成します。
$header = 'From: ' . mb_encode_mimeheader($fromName) . ' <' . $from . '>';
# メールを送信し、結果を返します。
# セーフモード☆レシピ283☆(セーフモードとは?)がOnの場合は第5引数が使えません。
if (ini_get('safe_mode')) {
$result = mb_send_mail($to, $subject, $body, $header);
} else {
$result = mb_send_mail($to, $subject, $body, $header, '-f' . $returnPath);
}
return $result;
}
/* ?>終了タグ省略 ☆レシピ001☆(サーバーのPHP情報を知りたい) */