メールを送信するサンプルコード。
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 |
$to = "hanako@example.com"; $from = "taro@example.com"; $bcc = "takeo@example.com"; $return = "support@example.com"; $subject = "Greetings"; $body = "Hello\n"; $body .= "How are you doing?\n"; mb_language("ja"); mb_internal_encoding("UTF-8"); $subject = mb_convert_encoding($subject, "ISO-2022-JP", "AUTO"); $subject = mb_encode_mimeheader($subject); $headers = "MIME-Version: 1.0 \n"; $headers .= "From: " . $from . "\n"; $headers .= "Bcc: " . $bcc . "\n"; $parameters = "-f " . $return; if (!mb_send_mail($to, $subject, $body, $headers, $parameters)) { echo "mb_send_mail() failed.\n"; return false; } return true; |