01.
<?php
02.
session_cache_limiter(
'nocache'
);
03.
session_start();
04.
05.
$page_title
=
"メール送信"
;
06.
07.
08.
?>
09.
<!DOCTYPE html>
10.
<html lang=
"ja"
>
11.
<head>
12.
<meta content=
"width=device-width initial-scale=1.0 minimum-scale=1.0 maximum-scale=1.0 user-scalable=no"
name=
"viewport"
>
13.
<meta charset=
"UTF-8"
>
14.
<link rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css"
>
15.
<title><?=
$page_title
?></title>
16.
<style>
17.
#main {
18.
padding: 20px 0px 20px 100px;
19.
}
20.
21.
.btn {
22.
width: 150px;
23.
}
24.
25.
.address {
26.
width: 300px;
27.
}
28.
</style>
29.
<script>
30.
function
checkSubmit() {
31.
32.
if
( !confirm(
"メールを送信しますか?"
) ) {
33.
return
false;
34.
}
35.
36.
return
true;
37.
38.
}
39.
</script>
40.
</head>
41.
<body>
42.
<h3><?=
$page_title
?></h3>
43.
44.
<div id=
"main"
>
45.
<form method=
"post"
onsubmit=
'return checkSubmit()'
>
46.
47.
<p>宛 先:<input
class
=
"address"
type=
"email"
required name=
"to"
value=
"<?= $_POST["
to
"] ?>"
></p>
48.
<p>件 名:<input type=
"text"
name=
"subject"
value=
"<?= $_POST["
subject
"] ?>"
></p>
49.
<p>本 文:<input type=
"text"
name=
"body"
value=
"<?= $_POST["
body
"] ?>"
></p>
50.
<p><input
class
=
"btn"
type=
"submit"
value=
"送信"
></p>
51.
<p></p>
52.
<p>アカウント:<input
class
=
"address"
type=
"email"
required name=
"from"
value=
"<?= $_POST["
from
"] ?>"
></p>
53.
54.
</form>
55.
56.
<input
class
=
"btn"
type=
"button"
value=
"リセット"
onclick=
'location.href="<?= $_SERVER["PHP_SELF"] ?>"'
>
57.
</div>
58.
59.
<?php
60.
mb_language(
"Japanese"
);
61.
mb_internal_encoding(
"UTF-8"
);
62.
63.
if
(
$_SERVER
[
"REQUEST_METHOD"
] ==
"POST"
) {
64.
65.
$from_header
=
"From: "
. mb_encode_mimeheader( mb_convert_encoding(
"差出人"
,
"iso-2022-jp"
) );
66.
67.
68.
$from_header
.=
" <{$_POST["
from
"]}>"
;
69.
70.
$result
= mb_send_mail(
$_POST
[
"to"
],
$_POST
[
"subject"
],
$_POST
[
"body"
],
$from_header
);
71.
if
(
$result
) {
72.
print
'メールを送信しました'
;
73.
}
74.
else
{
75.
print
'メール送信に失敗しました'
;
76.
}
77.
78.
}
79.
80.
print
"<pre>"
;
81.
print_r(
$_POST
);
82.
print
"</pre>"
;
83.
84.
?>
85.
</body>
86.
</html>