コメント |
@nifty LaCoocan では、メール転送の設定で 50 個までメールアドレスを作成
できるのですが、転送に使えるのは一つだけで、他は CGI を実行する事ができる
ようになっています。そこで、PHP でメールを送信すれば、全て転送に利用
できます
@DIV
<?
header( "pragma: no-cache" );
header( "Expires: Wed, 31 May 2000 14:59:58 GMT" );
header( "Cache-control: no-cache" );
header( "Content-Type: text/javascript; Charset=euc-jp" );
// メールデータ入力
$input = stream_get_contents(STDIN);
// デバッグ用
$f = uniqid().".log";
file_put_contents( $f, $input );
// メールデコード用 Pear ライブラリ
require_once 'Mail/mimeDecode.php';
// 転送用
$params['include_bodies'] = true;
$params['decode_bodies'] = false;
$params['decode_headers'] = false;
$params['crlf'] = "\r\n";
$decoder = new Mail_mimeDecode($input);
$structure = $decoder->decode($params);
// 本文に From データを JIS で追加する為
$params2['include_bodies'] = true;
$params2['decode_bodies'] = false;
$params2['decode_headers'] = true;
$params2['crlf'] = "\r\n";
$decoder2 = new Mail_mimeDecode($input);
$structure2 = $decoder2->decode($params2);
// デバッグ用
$result = print_r($structure,true);
$f = uniqid().".log";
file_put_contents( $f, $result );
// sendmail で送信
$ret = mail(
"転送先メールアドレス",
$structure->headers['subject'],
$structure->body."\nFrom: ".$structure2->headers['from'],
"From: サービスで登録したメールアドレス"
);
if ( $ret === false ) {
$result = "NG";
}
else {
$result = "OK";
}
// デバッグ用
$f = uniqid().".log";
file_put_contents( $f, $result );
?>
OK
@END |