Xserverでの空メール実装について

このQ&Aのポイント
  • Xserverで空メールを実装しようとしています。マニュアルを参考に設定を行いましたが、うまく動作しません。
  • 携帯電話から送信しても返信がUndelivered Mail Returned to Senderとなってしまいます。
  • サーバー側の設定が必要なのかどうかについて教えてください。
回答を見る
  • ベストアンサー

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', 'エラーログのパス'); ?> よろしくお願いします。

  • Dena
  • お礼率14% (1/7)
  • PHP
  • 回答数7
  • ありがとう数4

質問者が選んだベストアンサー

  • ベストアンサー
  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.7

エラーログを採るにあたっては、php.iniで以下を設定すればよいです。 error_reporting = (任意の値) log_errors = On error_log = "(ログファイルのパス)" サーバの環境がよくわかりませんが、ログファイルは予め書き込み可能なファイルとして作成しておく方が無難です。 ブラウザにエラーメッセージが表示されないということですが、まずはphp.iniの設定が正しく反映されているかphpinfo()で確認してみてください(確認済みでしたらすいません)。 うっかりコメントアウトしたままだったとかないですかね。

Dena
質問者

お礼

回答ありがとうございます。 解決しました! php.iniの設定が正しく反映されているかについて /○○○○/□□□□/sippai.phpに正しく反映されていませんでした。 php.iniファイルを作成し、配置していたのですが、配置先が誤っていたため、 反映されていませんでした。 こちらで配置できる一番上の階層にphp.iniを配置することで、エラーログをブラウザで確認することができました。 /○○○○/□□□□/sippai.phpのエラーログを確認できるようになったことで、PEARライブラリの呼び出しに失敗していることがわかりました。 原因は恥ずかしいですがスクリプトの記述ミスでした。 UmJammerさんのご指摘がなければ、気づくことができず解決はできなかったと思います。 PHPに触れるようになって1ヶ月程ですが、とても勉強になりました。 本当にありがとうございました。

その他の回答 (6)

  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.6

返送されるメールの内容は前とは異なってますよね、ということは一応前進してると思いますよ。 メッセージの内容は書かれたものがすべてですか? それだけだとちょっと原因の特定が難しい気もするので、その場合はPHPのエラーログを採ってみてください。 あとは方法自体が正しいかどうかを確認するには、もっと簡単なスクリプトを実行させることです。 たとえばログファイルに適当なメッセージを書き込むものとか簡単です。

Dena
質問者

補足

回答ありがとうございます >PHPのエラーログを採ってみてください。 エラーログの採り方で調べてみましたが、php.iniの設定で error_reporting=E_ALL & ~E_NOTICE display_errors=On display_startup_errors=On log_errors=On のようにすれば良いということでしょうか? php.iniの設定を行うことはxserverではできますが、もし php.iniの設定が行えない場合は、PHPファイルに ini_set('display_errors',0); ini_set('log_errors',1); のようにすれば良いということでしょうか?。 今回質問させていただいた時点からそうだったのですが、Webブラウザ上でエラーが全く表示されない(白紙のページ)という問題にも直面しています。サポートに問い合わせたところ、「display_errors=Onにしてください。」との回答でした。しかし設定は既にdisplay_errors=Onになっていました。再度サポートに問い合わせてみます。 <?php print("ababa") print(ababa"); print("ababa; ?> のエラーメッセージがWebブラウザ上で表示されません;; アドバイスありましたら、教えてください。よろしくお願いします。 回答を参考に頑張ります。

  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.5

たびたびすいません。 #!/usr/bin/php5で改行するようにしてください。 以下のような具合です。 #!/usr/bin/php5 <?PHP … ?>

Dena
質問者

補足

返事が遅くなりすいません。 #!/usr/bin/php5 <?PHP … ?> といった具合で、修正してみました。が、 This is the Postfix program at host △△△.xserver.jp. I'm sorry to have to inform you that your message could not be delivered to one or more reci 添付あり:Mail と返信されてきてしまいました。 添付されたものはなぜかサーバーとの接続が切れました、と 内容を把握できませんでした。 おまじないが効かなかったのでしょうか? 現在、「メールの振り分け設定」ではなく.mailfilterに書き込むことでエラーがなくならないか等、試行錯誤中です。 他に考えられる原因があるようでしたら、教えていただけませんか? よろしくお願いします。

  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.4

あー、いわゆる「おまじない」を付けとかないとだめでしたかね。 ファイルの先頭(PHPの開始タグより前)に  #!/usr/bin/php5 と書き足してみてください。

  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.3

>どのようにして実行権限を付与することができるのかわかりません。 UNIXコマンドの chmod で権限を変更することができます。 XserverはSSHで接続できないようなのでFTPクライアントでこれを行うか、あとはPHPスクリプトからコマンドを実行するという方法もあります。 >>パイプの後にphpへのパスが書かれていないのですが、実際は書かれているのでしょうか。 >書いていません。 Xserverの設定を見てみました。別にphpのパスはなくてもいいようですね。ここはとりあえず気にしないでください。

Dena
質問者

補足

実行権限の変更をすることができました! 教えていただいたFTPクライアントで変更できました。 ありがとうございます。 しかし、変更後にメールを送信し、返信内容を確認すると <○○○○○@△△△△>: Command died with status 2: "/usr/bin/maildrop". Command output: /○○○○/□□□□/sippai.php: line 1: ?php_: No such file or directory /○○○○/□□□□/sippai.php line 2: _: command not found /○○○○/□□□□/sippai.php: line 3: //PEAR::MailCu_: No such file or directory /○○○○/□□□□/sippai.php: line 4: //xserverp_: No such file or directory /○○○○/□□□□/sippai.php: line 5: require_once: command not found /○○○○/□□□□/sippai.php: line 5: _: command not found /○○○○/□□□□/sippai.php: line 6: //[Jp_: No such file or directory /○○○○/□□□□/sippai.php: | | | /○○○○/□□□□/sippai.php: line 18: syntax error near unexpected token `(' /○○○○/□□□□/sippai.php: line 18: `$source = file_get_contents("php://stdin");_' と返信されました。 このエラーだらけの原因がわかりません。 http://itunesipod.net/modules/pukiwiki/41.html こちらのサイトを参考にPEAR、Mail、Mail_mimeDecodeのパッケージをインストールしました。 MailやMail_mimeDecodeを呼び出せていないのでしょうか。 解決する方法を教えていただけないでしょうか。 よろしくお願いします。

  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.2

Permission deniedってありますね。 sippai.phpに実行権限を付与する必要があります。 ところで、質問文中の例示ではパイプの後にphpへのパスが書かれていないのですが、実際は書かれているのでしょうか。

Dena
質問者

補足

>sippai.phpに実行権限を付与する必要があります。 どのようにして実行権限を付与することができるのかわかりません。 >パイプの後にphpへのパスが書かれていないのですが、実際は書かれているのでしょうか。 書いていません。 1.メールを受信したらPHPプログラムにメールデータを送る 2.データを受け取ってメールの中身解析し 送信元のアドレス取得し、そのアドレスに返信する 1をxserverの「メールの振り分け設定」、2を記載したスクリプトのみ で行えると思っていました。知識に乏しいため何が必要なのかわかりません。教えていただけないでしょうか。 よろしくお願いします。

  • UmJammer
  • ベストアンサー率58% (115/196)
回答No.1

返送されたメールの本文に何かメッセージはありませんか?

Dena
質問者

補足

>返送されたメールの本文に何かメッセージはありませんか? 以下のメッセージが返送されました。 --○○○○.□□□□□/△△△.xserver.jp Content-Description:Notification Content-Type:text/plain;charset=ISO-2022-JP This is the Postfix program at host △△△.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 <○○○○○@△△△△>: Command died with status 126: "/usr/bin/maildrop". Command output: sh: /○○○○/□□□□/sippai.php: Permission denied --○○○○.□□□□□/△△△.xserver.jp Content-Description:Delivery report Content-Type:message/delivery-status Reporting-MTA: dns; △△△.xserver.jp X-Postfix-Queue-ID: □□□□□ X-Postfix-Sender: rfc822; □□□@○○○ Arrival-Date: Tue, 30 Jun 2009 16:52:37 +0900 (JST) Final-Recipient: rfc822; ○○○○○@△△△△ Action: failed Status: 5.0.0 Diagnostic-Code: X-Postfix; Command died with status 126: "/usr/bin/maildrop". Command output: sh: /○○○○/□□□□/sippai.php: Permission denied --○○○○.□□□□□/△△△.xserver.jp Content-Description:Undelivered Message Content-Type:message/rfc822 Received: from △△△.xserver.jp (oooo.xserver.jp [127.0.0.1]) by △△△.xserver.jp (Postfix) with ESMTP id ○○○○ for <○○○○○@△△△△>; Tue, 30 Jun 2009 16:52:37 +0900 (JST) Received: from oooo.xserver.jp (127.0.0.1) by △△△.xserver.jp (F-Secure/virusgw_smtp/301/△△△.xserver.jp); Tue, 30 Jun 2009 16:52:37 +0900 (JST) X-Virus-Status: clean(F-Secure/virusgw_smtp/301/△△△.xserver.jp) Received: from mmrts040p01c.softbank.ne.jp (mmrts040p01c.softbank.ne.jp [123.108.236.92]) by △△△.xserver.jp (Postfix) with SMTP id 1E22D858121 for <○○○○○@△△△△>; Tue, 30 Jun 2009 16:52:36 +0900 (JST) Subject: =?ISO-2022-JP?B?GyRCJC0kaSRzGyhC?= Mime-Version: 1.0 Content-Type:text/plain;charset=ISO-2022-JP Content-Transfer-Encoding:7bit Date: Tue, 30 Jun 2009 16:52:43 +0900 Message-ID: <11111111111111.2222222222222> From: <□□□@○○○> To: ○○○○○@△△△△ Sender:□□□@○○○ X-Priority: 3 --○○○○.□□□□□/△△△.xserver.jp--

関連する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
  • 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
  • pearのMailライブラリがうまくいきません

    自分で解決できなかったので、申し訳ないですが他力本願させていただきます。 空メール登録のシステムを作っています。 スクリプト以前に、メールを送ると 「Fw:Returned mail: see transcript for details」のタイトルで 以下のような文章でかえってきます。 rom: Mail Delivery Subsystem <MAILER-DAEMON@www.abc.com> Date: Fri, 23 Jan 2009 19:15:27 +0900 To: <hoge@ezweb.ne.jp> Subject: Returned mail: see transcript for details The original message was received at Fri, 23 Jan 2009 19:15:27 +0900 from xxxxxxxxxx.ezweb.ne.jp [11.111.11.123] ----- The following addresses had permanent fatal errors ----- "|php /var/www/hoge-html/hogehoge/empty_mail.php" (reason: Service unavailable) (expanded from: <hohogege@hoge.jp>) ----- Transcript of session follows ----- smrsh: "empty_mail.php" not available for sendmail programs (stat failed) 554 5.0.0 Service unavailable aliasesの設定には以下のようにしています。パスはあっています。 hohogege:"|php /var/www/hoge-html/hogehoge/empty_mail.phpp" sendmail, postfixはインストールされています。 ちなみにスクリプトは以下のように書きました。 //PEAR::Mailライブラリ require_once 'Mail.php'; //PEAR::Mail_mimeライブラリ require_once '/usr/share/pear/Mail/mimeDecode.php'; //メールソースを読み込む $source = file_get_contents("php://stdin"); if(!souce){ exit(); } //メールを解析する。 $decoder = new Mail_mimeDecode($source); $structure = $decoder->decode($params); //送信元を取得する。 $form = $structure->headers['from']; $form = mb_decode_mimeheader($from); $form = mb_convert_encoding($form, mb_internal_encoding(), 'auto'); if(preg_match( '/<(.*?)>$/', $from, $match)){ $from = $match[1]; } $from = trim($from); $from = strtolower($from); //送信データを設定する $recipients = $from; $new_from = 'hogehoge@abc.jp'; $subject = 'empty mail ok'; $body = 'http://www.hogehoge.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);

    • ベストアンサー
    • PHP
  • PHP foreachを使ってループしたい

    こんばんは。 PHPで複数の宛先でメールを送信したいと思っております。 そこでメールフォームでまず mail.php foreach ($arr as $value) { print'<input type="hidden" name="mail[]" value="'. $value .'">'; } f-mail.php $_POST['mail']で取得しそれを$valとして、print_r($val);で表示すると Array ( [0] => アドレスA [1] =>アドレスB ) と表示されます。 その複数のアドレスを //PEAR::MailCu require_once '/Mail.php'; //PEAR::Mail_mimeCu require_once '/mimeDecode.php'; //送信データを設定する $recipients= $val; $new_from = 'hoge@hoge.com'; $subject = mb_encode_mimeheader(mb_convert_encoding("$subject1", "JIS", "auto"), "JIS"); $body =$body1; //メールを送信する $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); ・LoopでToを変更しながら繰り返し送信する事がしたいのですがforeachでどう設定していいかわかりません。マニュアルもみたのですが、混乱してしまったので ご指導、ご教授のほど宜しくお願い致します。

    • 締切済み
    • PHP
  • エックスサーバーで 空メール実行PHP

    エックスサーバーを借りています。 PHPの勉強を始めたばかりの初心者です。 空メールを送り、定型文を自動返信させたいのですが、うまくいきません。 どなたか何処が間違っているのが、教えていただけないでしょうか? 《設定内容》 エックスサーバーのメール振り分けは、 条件(キーワード)  ○○○@△△.△△△.jp 条件(場所)     あて先 条件(一致)     内容を含む 処理方法       | /usr /bin/php5 /home/サーバーID/ドメイン/public_html/empty_mail.php 【.htaccess】 php_value register_globals 1 php_value magic_quotes_gpc 0 php_value session.use_cookies 0 php_value session.use_trans_sid 0 php_value output_buffering 1 php_value output_handler mb_output_handler php_value default_charset EUC-JP php_value mbstring.language Japanese php_value mbstring.internal_encoding EUC-JP php_value mbstring.http_input EUC-JP php_value mbstring.http_output EUC-JP php_value mbstring.encoding_translation 1 php_value mbstring.detect_order auto php_value mbstring.substitute_character none 【php.ini】 safe_mode = off max_input_time = 60 output_buffering = none safe_mode_exec_dir = none upload_max_filesize = 10M variables_order = EGPCS dbx.colnames_case = lowercase HTTP input encoding translation = on mbstring.detect_order = auto mbstring.encoding_translation = on mbstring.http_input = auto mbstring.http_output = SJIS mbstring.internal_encoding = EUC-JP mbstring.language = Japanese session.save_path = /var/lib/php/session url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" 【empty_mail.php】 #!/usr/bin/php5 <?php require_once 'Mail/mail.php'; require_once 'Mail/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 = '○○○@△△.△△△.jp'; $subject = '=='; $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 sv○○○.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 <○○○@△△.△△△.jp>: Command died with status 126: "/usr/bin/maildrop". Command output: sh: /usr: is a directory 問題だらけだと思うのですが、どこをどう直していいのか わかりません。お願いします。

    • 締切済み
    • PHP
  • 空メール受信時 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

  • 空メールからの標準入力が受け取れません。

    よろしくお願いいたします。 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
  • 自動返信でのMail_mimeDecode

    //メールソースを読み込む $source = file_get_contents("php://stdin"); if(!$source){ exit(); } $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 = getbody($mail_data); if (!$MailBody) { print "cannot get MailBody"; // エラー処理 }// $MailBodyを使った処理 function getbody($arg) { if ($arg->ctype_primary == 'multipart') { foreach($arg->parts as $parts) { $ret = getbody($parts); if ($ret) { return $ret; } } } if ($arg->ctype_primary == 'text') { if ($arg->ctype_secondary == 'plain') { if (strtolower($arg->ctype_parameters['charset']) == 'iso-2022-jp') { return mb_convert_encoding($arg->body, "UTF-8", 'JIS'); } else { return $arg->body; } } } return false; } //メールを解析する $decoder = new Mail_mimeDecode($source); $structure = $decoder->decode($params); //送信元を取得する $mail = $structure->headers['from']; $mail = addslashes($mail); $mail = str_replace('"','',$mail); $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 = 'get@hoge.com'; mb_language('ja'); mb_internal_encoding('sjis'); $subject = mb_encode_mimeheader(mb_convert_encoding("登録URL", "JIS", "auto"), "JIS"); $body = "下記のURLをクリックして登録を行ってください http://hoge.com/regist.php?". $MailBody . "". session_name()."=". htmlspecialchars(session_id()); とメールを自分のHPに送る際に本文にデータがあるのですが、そのデータを取り出し登録URLに付加し、情報を維持させたいのですが、上記のソースですと$MailBodyに情報がはいっていません。ベテランさん!ご指導、ご教授お願い致します

    • ベストアンサー
    • PHP
  • PHPでHTMLメールを送信、文字化けします。

    Mail/mime.php を利用してHTMLメールの送信をしようとしています。 試行錯誤をしているのですが、どうしても文字化けしてしまいます。 データベースから取得したデータをHTMLメールにして送信したいのですが、 このままでは、タイトルはきちんと送れていますが、本分が文字化けします。 何か抜けたり、設定が変だったりはありますでしょうか? ご教授お願いいたします。 以下にソースを記しています。 データベースとPHPのソースはどちらも【UTF-8】です。 /*-------------------ここから データベースより取得----------*/ $recipients //送信先 $sender //送信元 $Subject //タイトル $body //本文 /*--------------------ここまでデータベースより取得--------------*/ mb_language("japanese"); mb_internal_encoding("UTF-8"); require_once("Mail.php"); require_once("Mail/mime.php"); $params = array( "host" => "自ドメイン", "port" => 587, "auth" => true, "username" => "送信元アカウント", "password" => "********" ); $mailObject = Mail::factory("smtp", $params); $mimeObject = new Mail_Mime("\n"); $mimeObject -> setHTMLBody($body); $bodyParam = array( "head_charset" => "ISO-2022-JP", "html_charset" => "Shift_Jis" ); $body = $mimeObject -> get($bodyParam); $addHeaders = array( "To" => "$recipients", "From" => "$sender", "Subject" => mb_encode_mimeheader("$Subject") ); $headers = $mimeObject -> headers($addHeaders); $mailObject -> send($recipients, $headers, $body);

    • ベストアンサー
    • PHP
  • Mail_mimeDecodeでメール本文取得

    index.php <form action="mailto:info@hoge.com" method="get" id="join"> <input type="hidden" name="body" value="<?php echo $friend;?>" /> </center></form> empty_mail.php $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 = getbody($mail_data); if (!$MailBody) { print "cannot get MailBody"; // エラー処理 }// $MailBodyを使った処理 function getbody($arg) { if ($arg->ctype_primary == 'multipart') { foreach($arg->parts as $parts) { $ret = getbody($parts); if ($ret) { return $ret; } } } if ($arg->ctype_primary == 'text') { if ($arg->ctype_secondary == 'plain') { if (strtolower($arg->ctype_parameters['charset']) == 'iso-2022-jp') { return mb_convert_encoding($arg->body, "UTF-8", 'JIS'); } else { return $arg->body; } } } return false; } //メールを解析する $decoder = new Mail_mimeDecode($source); $structure = $decoder->decode($params); //送信元を取得する $mail = $structure->headers['from']; $mail = addslashes($mail); $mail = str_replace('"','',$mail); $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 = 'info@hoge.com'; mb_language('ja'); mb_internal_encoding('sjis'); $subject = mb_encode_mimeheader(mb_convert_encoding("登録URL", "JIS", "auto"), "JIS"); $body = "下記のURLをクリックして登録を行ってください http://hoge/hoge.php?". $MailBody . "". session_name()."=". htmlspecialchars(session_id()); と$friendを登録フォーム画面にいくまで情報を維持したいのですが、ご教授お願いします。

    • ベストアンサー
    • PHP

専門家に質問してみよう