Skip to content

Instantly share code, notes, and snippets.

@caramelchocolate
Created April 20, 2020 08:51
Show Gist options
  • Save caramelchocolate/6fe819569eaacaa7ffea06ef1d1a01e6 to your computer and use it in GitHub Desktop.
Save caramelchocolate/6fe819569eaacaa7ffea06ef1d1a01e6 to your computer and use it in GitHub Desktop.
mail test
--TEST--
mail test
--INI--
sendmail_path=./stdout.sh
mail.add_x_header=off
mail.log=./mail.log
--FILE--
<?php
# pear run-tests mailtest.phpt
$to = 'example@example.com';
function encode_mimeheader($str) {
$str = mb_convert_encoding($str, "JIS");
$str = '=?'.'iso-2022-jp?B?'. base64_encode($str) .'?=';
return $str;
}
function mail_header ($headers = null) {
$headers .= "Mime-Version: 1.0\n";
$headers .= "Content-Transfer-Encoding: 7bit\n";
$headers .= "Content-Type: text/plain; charset=iso-2022-jp\n";
return $headers;
}
$to = 'example@example.com';
$body = 'body_test';
$subject = 'subject_test';
$subject = encode_mimeheader($subject);
$body = mb_convert_encoding($body, "JIS");
$headers = mail_header();
$add_param = '-f example@example.com';
mail($to, $subject, $body, $headers, $add_param);
?>
#!/bin/sh
echo "sendmail options: ${@}"
awk '{print $0}' < /dev/stdin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment