-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
46 lines (37 loc) · 986 Bytes
/
index.php
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
$to = 'test@example.com';
$subject = 'メールの送信テストです。';
$from = $_POST['from'] ?? '';
$message = $_POST['message'] ?? '';
if ($from && $message) {
if (sendEmail($from, $to, $subject, $message)) echo 'メールの送信に成功しました。';
else echo 'メールの送信に失敗しました。';
}
function sendEmail(string $from, string $to, string $subject, string $message): bool {
$headers = [
'From' => $from,
'Reply-To' => $from,
];
mb_language('ja');
mb_internal_encoding('UTF-8');
return mb_send_mail($to, $subject, $message, $headers);
}
?>
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
</head>
<body>
<hr>
<form method="post">
<p>
メールアドレス:<input type="text" name="from">
</p>
<p>
お問い合わせ内容:<textarea name="message"></textarea>
</p>
<input type="submit" value="送信する">
</form>
</body>
</html>