• 締切済み

空メール受信時 php8 さくらインターネット 

phpを8.0にバージョンアップしたら空メール受信時のphp起動が稼働しなくなりました。 稼働しなくなった理由や原因など教えていただきたいです。 よろしくお願いします。 過去のバージョン時に参考にしたサイトは以下の通りのものです http://www.aiwake.co.jp/modules/bulletin/index.php?page=article&storyid=3 -------------reply.php------------------------ #!/usr/local/bin/php -q <?php // PEARのパスを設定 $path = '/home/{さくらアカウント名}/pear/PEAR/'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Mail/mimeDecode.php'; // 受信メールから読み込み $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $params['input'] = file_get_contents("php://stdin"); $params['crlf'] = "\r\n"; if (!$params['input']) { // 読み込み失敗 exit(); } $structure = Mail_mimeDecode::decode($params); // Fromフィールド(会員のアドレス)の取得 $fromField = $structure->headers['from']; $fromField = addslashes($fromField); $fromField = str_replace('"','',$fromField); $fromField = preg_replace('/(^.*<|>$)/', '', $fromField); // 会員のアドレスを暗号化 $addr = base64_encode($fromField); // Subjectフィールド(広告コード)の取得 $subjectField = $structure->headers['subject']; $subjectField = mb_convert_encoding($subjectField,"UTF-8","JIS"); $ad = $subjectField; // メール作成 $to = $fromField; $fromAddr = "{メールアドレス}"; $from = "From: $fromAddr"; $subject = "{メールタイトル}"; $body = "{メール内容}"; // メール送信 if (mb_send_mail($to, $subject, $body, $from)) { exit(); } else { echo "メールの送信に失敗しました。\n"; exit(1); // エラーコード 1 を返す } ?> -------------reply.php------------------------   to "| /usr/local/bin/php -q /home/gayhiroba/MailBox/{さくらアカウント名}/reply.php" exit

みんなの回答

  • t_hirai
  • ベストアンサー率27% (157/577)
回答No.1

エラーメッセージとかありませんか? また、さくらインターネット側には問い合わせてみましたか?

関連するQ&A

  • 携帯からの空メールの処理

    こんにちは。今、PHP5.3で、携帯からの空メールを処理するプログラムを作っています。 具体的には、空メールが携帯から送られてくると、エイリアスでPHPプログラムに渡し、送信者に自動返信するというプログラムです。 現在、以下のようなプログラムを作っていますが、うまく動きません。 ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー <?php require_once("/opt/lampp/lib/php/PEAR.php"); // PEAR::Mailライブラリ require_once("/opt/lampp/lib/php/Mail.php"); // PEAR::Mail_mimeライブラリ require_once("/opt/lampp/lib/php/Mail/mimeDecode.php"); $params['include_bodies'] = false; $params['decode_bodies'] = false; $params['decode_headers'] = true; $params['input'] = file_get_contents("php://stdin"); $params['crlf'] = "\r\n"; //メールを解析する $structure = Mail_mimeDecode::decode($params); print_r($structure); //送信元を取得する $mail = $structure->headers['from']; $mail = addslashes($mail); $mail = str_replace('"','',$mail); preg_match("/<.*>/", $mail,$str); if($str[0]!=""){ $str=substr($str[0],1,strlen($str[0])-2); } $mail = $str; //送信データを設定する $recipients = $mail; $new_from = 'register@7ws.jp'; $subject = 'empty mail OK!'; $body ='登録が完了しました。'; $headers = "From:".$new_from; //メールを送信する $headers = array(); $headers['From'] = $new_from; $headers['To'] = $recipients; $headers['Subject'] = $subject; $headers['Sender'] = $new_from; $mail = Mail::factory('sendmail'); $result = $mail->send($recipients, $headers, $body); ?> ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー 参考にしたのは、http://www.phppro.jp/phptips/archives/vol35/1 と「PHP×携帯サイト デベロッパーズバイブル」です。 プログラムを実行しても、空メールの送信者のアドレスが取得できず、 送り先を空白のまま、メールを送信していまい、エラーとなります。 正常に送信者アドレスを取る方法をご存知の方が、いらっしゃいましたら、ご教授お願いします。 なお、$structure = Mail_mimeDecode::decode($params);の下で、 print_r($structure);を実行したところ、 print_r($structure); ( [headers] => Array ( [] => ) [ctype_primary] => text [ctype_secondary] => plain ) という表示なっていました。headersがArrayなのに空っぽなところに、 問題があるのではないかと思います。以上、よろしくお願いします。

    • ベストアンサー
    • PHP
  • 空メールからの標準入力が受け取れません。

    よろしくお願いいたします。 CentOS5.2 & PHP5(お名前.COMのVPSディフォルトです。) お名前.COMのVPSで空メールでのユーザー認識したいと思って います。説明いただいているサイトを参考に、以下のコードを動かして います。 空メールを送ってみると、 $sss=file_get_contents("php://stdin"); をコメントアウトしない場合は、 テストで作らせているテキストファイルもでき、返信メールが帰ります。 しかし、上記文を入れるとテストで作らせているテキストファイルも 返信もありません。 アドバイスいただければ助かります。 pearは Mail_Mime 1.8.0 stable Mail_mimeDecode 1.5.4 stable でインストールしてあります。 <?php //PEARのライブラリ読み込み require_once("/usr/share/pear/Mail/mimeDecode.php"); //メールソースを標準入力から読み込み $sss=file_get_contents("php://stdin"); $frm="AAAAAA"; if(!$source) { exit(); // 読み込み失敗 } //メール解析 $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $decoder = new Mail_mimeDecode($sss); $structure = $decoder->decode($params); $from = mb_convert_encoding(mb_decode_mimeheader($structure->headers['from']), mb_internal_encoding(), "auto"); $gdata="ddddddd".$sss.$frm; $ffp2="ggg.txt"; $fh=fopen($ffp2,"w"); fwrite($fh,$gdata); fclose($fh); $from="xxxxx@hhhhh.com"; //メール返信 $to = $from; $title = "空メールの返信(例)"; $body = "登録が完了しました。\n(実際は何も登録していません。)\n※このメールは配信専用です。\n返信されても対応は出来ませんので、ご了承下さい。"; $from = "From: support@XXXXXXXXX"; mb_internal_encoding("SJIS"); mb_language("japanese"); mb_send_mail($to, $title, $body, $from); ?>

    • 締切済み
    • PHP
  • Xserverでの空メール実装について

    Xserverで空メールを実装しようとしています。 しかしうまく動作しません。 マニュアルを参考に「メールの振り分け設定」より 条件:あて先が ○○○○○@△△△△ を一致する 処理方法:| /○○○○/□□□□/sippai.php へ 転送する としました。 しかし、携帯電話より○○○○○@△△△△へメール送信しても、 差出人:MAILER-DAEMON@△△△.xserver.jp 件名:Undelivered Mail Returned to Sender と返信されてしまいます。 サーバー側の設定が何か必要なのでしょうか? スクリプトを以下に記載します。 使用スクリプト;PHP5、ライブラリ;PEAR <?php //PEAR::MailCu require_once '/aaaaaa/bbbb/cccc/ddddd/eeeee/fff/Mail.php'; //PEAR::Mail_mimeCu require_once '//aaaaaa/bbbb/cccc/ddddd/eeeee/ggg/mimeDecode.php'; //メールソースを読み込む $source = file_get_contents("php://stdin"); if(!$source){ exit(); } //メールを解析する $decoder = new Mail_mimeDecode($source); $structure = $decoder->decode($params); //送信元を取得する $from = $structure -> headers['from']; $from = mb_decode_mimeheader($from); $from = mb_convert_encoding($from, mb_internal_encoding(),'auto'); if(preg_match( '/<(.*?)>$/' , $from , $match)){ $from = $match[1]; } $from = trim($from); $from = strtolower($from); //送信データを設定する $recipients = $from; $new_from = '○○○○○@△△△△'; $subject = 'empty mail ok!'; $body = 'http://fmob.jp'; //メールを送信する $headers = array(); $headers['From'] = $new_from; $headers['To'] = $recipients; $headers['Subject'] = $subject; $headers['Sender'] = $new_from; $mail = Mail::factory('sendmail'); $result = $mail->send($recipients, $headers, $body); ini_set('log_errors', '1'); ini_set('error_log', 'エラーログのパス'); ?> よろしくお願いします。

    • ベストアンサー
    • PHP
  • PHP5での空メールが実行されない

    現在PHP5を利用して携帯の空メールを実装しており、3日ほどトライし続けておりますが、携帯側にエラーが返信される所で先に進めずにいます(;;)プログラムは勉強し始めて4ヶ月程度の未熟者です。どなたか是非ご教授頂ければと思います。よろしくお願いします!! ちなみに、pearは使えているのを、他のライブラリで確認しました。 【使用言語とライブラリ】 PHP5、pearの『Mail.php』『mimeDecode.php』 【参考書籍】 PHP携帯 デベロッパーズバイブル 【利用サーバー】 Xサーバー 【メールの振り分け設定】 『条件』あて先が ○○○@△△.com を一致する 『処理方法』 | /home/サーバーID/ドメイン/public_html/フォルダ名/フォルダ名/empty_mail.php へ 転送する 【PHPのソース】 #!/usr/bin/php5 <?php //PEAR::Mailライブラリ ini_set('include_path', '/home/サーバーID/ドメイン/public_html/pear/PEAR'); require_once 'Mail/Mail.php'; //PEAR::Mail_mimeライブラリ ini_set('include_path', '/home/サーバーID/ドメイン/public_html/pear/PEAR'); require_once 'Mail/mimeDecode.php'; //メールソースを読み込む $source = file_get_contents("php://stdin","r"); if(!$source){ exit("標準入力に失敗"); } //メールを解析する $decoder = new Mail_mimeDecode($source); $structure = $decoder->decode($params); //送信元を取得する $from = $structure -> headers['from']; $from = mb_decode_mimeheader($from); $from = mb_convert_encoding($from, mb_internal_encoding(),'auto'); if(preg_match( '/<(.*?)>$/' , $from , $match)){ $from = $match[1]; } $from = trim($from); $from = strtolower($from); //送信データを設定する $recipients = $from; $new_from = ○○○@△△.com'; $subject = 'empty mail ok!'; $body = '(仮)こんにちわ'; //メールを送信する $headers = array(); $headers['From'] = $new_from; $headers['To'] = $recipients; $headers['Subject'] = $subject; $headers['Sender'] = $new_from; $mail = Mail::factory('sendmail'); $result = $mail->send($recipients, $headers, $body); ini_set('log_errors', '1'); ini_set('error_log', 'エラーです'); 【エラー内容(すごく長いですが…)】 This is the Postfix program at host sv225.xserver.jp. I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below. For further assistance, please send mail to <postmaster> If you do so, please include this problem report. You can delete your own text from the attached returned message. The Postfix program <○○○@△△.com>: Command died with status 255: "/usr/bin/maildrop". Command output: PHP Warning: require_once(/home/サーバーID/ドメイン名/public_html/pear/PEAR/Mail/Mail.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream: No such file or directory in /home/サーバーID/ドメイン名/public_html/mobile_search/gotempty_mail2.php on line 7 PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/home/サーバーID/ドメイン名/public_html/pear/PEAR/Mail/Mail.php' (include_path='home/サーバーID/ドメイン名/public_html/pear/PEAR') in /home/サーバーID/ドメイン名/public_html/mobile_search/gotempty_mail2.php on line 7 X-Powered-By: PHP/5.1.6_ Content-type: text/html_ _ とても煩雑でごめんなさい(;;) どうかよろしくお願いします。

    • ベストアンサー
    • PHP
  • メール受信エラー【Net/POP3.php】

    自作blogを作っています。 試行錯誤しているのですが、解決できないので質問します。 モブログを付加させようとまずはメール受信プログラムを 作りましたが、動きません。login errorがでます。 この前にimapも作って走らせたのですが、動きませんでした。 http://nescio.seesaa.net/article/67124976.html を見て、引数も設定し直しましたが、ダメでした。 Net/pop3でなくてもよいのですが、解決法が あったら教えてください。ロリポップを使っています。 <?php require 'Net/POP3.php'; require_once("Mail/mimeDecode.php"); $mail_conf = array( 'host' => 'mail??.lolipop.jp', 'port' => '110', 'user' => 'lolipop.jp-bbbb', 'pass' => 'aaaaa', 'auth' => 'true', ); $pop3 =& new Net_POP3; $con = $pop3->connect( $mail_conf['host'], $mail_conf['port'], $mail_conf['auth']); if(PEAR::isError($con)){ die("接続エラー"); } $login = $pop3->login( $mail_conf['user'], $mail_conf['pass'],$mail_conf['auth']); if(PEAR::isError($login)){ die("login error"); } $maillist = $pop3->getListing(); if ( is_array( $maillist) && 0 < count( $maillist)) { foreach ( $maillist as $mailinfo) { $m_id = $mailinfo[ 'msg_id']; $mail = $pop3->getMsg($m_id); $params['include_bodies'] = true; $params['decode_bodies'] = false; $params['decode_headers'] = true; $params['input'] = $mail; $structure = Mail_mimeDecode::decode( $params); print_r($structure); } } $pop3->disconnect(); ?>

    • ベストアンサー
    • PHP
  • PHPのmimeDecode.php について

    Redhat Linux4 で、メールを受信した際、添付ファイルがあれば 特定のフォルダに添付ファイルを保存するPHPを作っています。 以下のメール受信時にPHPプログラムを起動すると、 添付ファイル付きメールなのに、 $structure->ctype_primary = 'multipart' となってくれず 途方にくれています。 どなたかご教授いただきたくよろしくお願いいたします。 require_once("Mail/mimeDecode.php"); $input = file_get_contents("php://stdin"); $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $decoder = new Mail_mimeDecode($input, "\r\n"); $structure = $decoder->decode($params); $GB['sMailBody']=$structure->ctype_primary; この結果、$GB['sMailBody']は、text となってしまいます。

    • 締切済み
    • PHP
  • 携帯サイトの画像アップロード

    Linaxサーバー初心者です。 今携帯サイトの画像アップロードプログラムを作成して いるのですが、どうしても原因が分からず、困っております。どなたか分かる方がいらっしゃいましたら御教授お願いできませんでしょうか。 ▼プログラムのフロー snspost宛てのメールを受信するとメールプログラム(snspost.php)が起動し、メール解析プログラム(postdialy.php)にメールデータを渡し、解析処理を行います。 ▼/etc/aliases の内容 snspost:"|/usr/bin/php /var/www/html/snspost.php" ▼postdialy.php の内容 <?php $path = '/usr/lib/php/pear/'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once "Mail/mimeDecode.php"; require_once "DBUtil.php"; require_once "MailParser.php"; require_once "AuthUtil.php"; // コンフィグ読み込み($configに設定内容が入る) require_once "Config.php"; // 画像格納場所 $image_dir = $config['image_dir']; // 初期化 $images = array(); // 処理実行 $data = $_POST['content']; // メールをデコードする $decoder = new Mail_mimeDecode($data); $structure = $decoder->decode(array( 'include_bodies' => true, 'decode_bodies' => true, 'decode_headers' => true, )); // メールの宛先でユーザーを識別する $to = $structure->headers['to']; // 宛先は[prefix][user_id]_[auth_code]@ホスト名 $pattern = '!^'.$config['prefix'].'([0-9].*?)_([0-9a-z]{6})@.*?!'; $user = null; if (preg_match($pattern, $to, $matches)) { $user_id = $matches[1]; $auth_code = $matches[2]; if ($db = connectDB($db_user, $db_pass, $db_name, $db_host, true)) { // 投稿内容を記録する $query = "SELECT * from sns_users where id=?"; $user = execQuery($db, $query, array($user_id)); if ($user) { $user = $user[0]; } // データベースを閉じる closeDB($db);}} ――――途中省略―――――――――――――― if ($image_save_path) { // 題名取得 $subject = $structure->headers['subject']; $subject = mb_convert_encoding($subject, "utf-8", array('ISO-2022-JP', 'sjis-win', 'utf-8', 'eucjp-win')); // 差出人取得 $from = getFrom($structure->headers['from']); // 本文取得 $body = getBody($structure); $body = mb_convert_encoding($body, "utf-8", array('ISO-2022-JP', 'sjis-win', 'utf-8', 'eucjp-win')); $params = array(); $params[] = $user['id']; $params[] = $subject; $params[] = $body; $params[] = $image_save_path; // データベースへ接続する if ($db = connectDB($db_user, $db_pass, $db_name, $db_host, true)) { // 投稿内容を記録する $query = "INSERT INTO sns_diaries(user_id,subject,contents,image_path,posted_at)". " VALUES (?,?,?,?,NOW())"; execQuery($db, $query, $params); // データベースを閉じる closeDB($db); }}} ?>以上ここまで ちなみに、送り先のsnspost@(ドメイン名)を見ると受信はできています。他に必要な情報などございましたら是非ご連絡いただけますと幸いです。どなたかお助けください。どうかお願いいたします。

    • ベストアンサー
    • PHP
  • PEARのmimeDecodeでメール解析をしたい

    レンタルサーバにPEARをインストールし、 mimeDecode.phpを使って、メールを解析したいのですが、 上手くいきません。 下記のサイトを参考にしましたが、やはりできませんでした。 http://d.hatena.ne.jp/makotoworld/20071106/1194309820 http://www.abe-tatsuya.com/web_prog/php/mail2php.php メールを分解するファイル(.php)では、 file_get_contents("php://stdin")のようなカタチで、 メール情報はキャッチできています(確認済みです)が、 それを、 $params['include_bodies'] = true; $params['decode_bodies'] = true; $params['decode_headers'] = true; $params['input'] = file_get_contents("php://stdin"); // 標準入力 $params['crlf'] = "\r\n"; $mail_data = Mail_mimeDecode::decode($params); #-- 本文の取得 $MailBody = $mail_data->body; $MailBody = mb_convert_encoding($MailBody,"UTF-8","JIS"); としても、取り出せないのです。 (つまり、$MailBody は空っぽのままなのです。) さらに、 #-- From フィールドの取得 $FromAddress = $mail_data->headers['from']; #-- To フィールドの取得 $ToAddress = $mail_data->headers['to']; としている部分では、error_reportingが、 Notice: Undefined index: from in~~ Notice: Undefined index: to in~~ と、エラーを吐いています。 これも謎です…。一体、どういうことになっているんでしょうね?!汗 ・パスの書き方に誤りがあり、 正常にPEARにアクセス(利用)できていない? ・そもそも、インストールが怪しい? ・上記の、参考にした2サイトでは、 mimeDecode.phpの扱い方が違うのですが、この違いとは? これは、PEARのバージョンの新旧の問題? だとすると、今となっては、 どちらか一方しか使えない、もしくは、両方とも使えない? つまり、サイトを参考にして書いたコードがそもそも古くて使い物にならない? ・ファイルのパーミッションの問題?(保存形式はEUCとしています) 以上の点が、気になっています。 この事態を打開するためには、どう切り分けながら改善していったらよろしいでしょうか。 どなたかお詳しい方、どうか教えて下さい。 なお、 FFFTPにより、PEARのファイル群が置かれていることは確認しています。 (mimeDecode.phpもあります。) コードの冒頭は、 #!/usr/local/bin/php <?php error_reporting(E_ALL); としています。 レンタルサーバは、さくらインターネットのスタンダードプランです。 PHPバージョンは、5.2.14。 PEARは、最近、http://pear.php.net/go-pear経由でインストールしました。 長くなりましたが、宜しくお願い致します。

    • ベストアンサー
    • PHP
  • PHPで外部SMTPサーバーを利用したメールの送信方法

    PHPで外部SMTPサーバーを利用したメールの送信方法を調べています。 過去の事例からPEARを使用すれば良いことが分かりPEARをインストールしたのですが、 実行すると「$smtp = Mail::factory("smtp", $params);」の所で、 「Fatal error: Class 'Mail' not found in C:\Inetpub\wwwroot\Mail.php on line 14」と なってしまいます。 PEARのインストール後はサーバーの再起動は行っております。 ※環境 OS:WindowsXP Pro SP3 WebServer:IIS PHP:Ver.5.2.6 ※PEARのインストール状態 C:\Documents and Settings\horie>C:\php\pear list PHP Warning: Module 'mbstring' already loaded in Unknown on line 0 INSTALLED PACKAGES, CHANNEL PEAR.PHP.NET: ========================================= PACKAGE VERSION STATE Archive_Tar 1.3.2 stable Console_Getopt 1.2.3 stable PEAR 1.7.1 stable Structures_Graph 1.0.2 stable ※Mail.php <?php $params["host"] = "smtp.mail.yahoo.co.jp"; $params["auth"] = true; $params["username"] = "AAA-BBB"; $params["password"] = "9999"; $sender = "aaa**@yahoo.co.jp"; $recipient = "bbb**@yahoo.co.jp"; $subject = "TEST"; $subject = mb_convert_encoding($subject, "jis", "sjis"); $subject = mb_encode_mimeheader($subject, "jis"); $message = "テストメッセージ"; $message = mb_convert_encoding($message, "jis", "sjis"); require_once 'Mail.php'; $smtp = Mail::factory("smtp", $params); if (PEAR::isError($smtp)) die($smtp->getMessage()); $headers['From'] = $sender; $headers['Subject'] = $subject; $headers['MIME-Version'] = "1.0"; $headers['Content-Type'] = 'text/plain; charset="iso-2022-jp"'; $headers['Content-Transfer-Encoding'] = "8bit"; $headers['X-Mailer'] = "PHP PEAR/Mail(smtp)"; $error = $smtp->send($recipient, $headers, $message); if (PEAR::isError($error)) die($error->getMessage()); exit("メッセージを送信しました"); ?>

    • ベストアンサー
    • PHP
  • メールを受信した後、特定メールを削除

    メールフィルターで受信後にプログラムを起動し特定のメールだけ削除したいのですが可能でしょうか? メールフィルターは以下です。CCはメールボックスから削除しない。 cc "| /home/○○/○○/mailgo.php" PEARを使ってまず受信します。 $params['input'] = file_get_contents("php://stdin"); $structure = Mail_mimeDecode::decode($params); メールのファイル名などを取得し、その後、削除したいメールも特定できたのですが どうすればいいのでしょうか?

    • 締切済み
    • PHP

専門家に質問してみよう