• 締切済み

Ethnaでメール送信するには?

下記のサイトを参考にEthnaの勉強をしています。 http://ethna.jp/ethna-document-dev_guide-app-mail.html ※環境はXAMPPを使用しています。 参考にしながらサンプルを作成していますがうまくいきません。 tplファイルは以下のフォルダに置いています。 C:\xampp\htdocs\sample\template\ja\mail [内容] From: xxx@yahoo.co.jp Subject: 入会に成功しました。 ようこそ{$username}さん。 うんたらかんたらほげほげ。 phpファイルは以下の場所に置いています。 C:\xampp\htdocs\sample\www [内容] <?php include_once('C:\xampp\php\PEAR\Ethna\class/Ethna_MailSender.php'); $ethna_mail =& new Ethna_MailSender($this->backend); $ethna_mail->send('xxx@yahoo.co.jp', 'welcome.tpl', array('username' => $regist_user)); ?> ブラウザで実行したら下記のエラーが表示されました。 Fatal error: Using $this when not in object context in C:\xampp\htdocs\sample\www\welcome.php on line 4 Ethnaでメール送信するにはどのようにしたらいいのでしょうか? アドバイス宜しくお願いします。

  • PHP
  • 回答数1
  • ありがとう数0

みんなの回答

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

適当にアクションクラスを作って(定義して)、適当なメソッドに例示した処理を書けばよいでしょう。

関連するQ&A

  • Ethnaの設定について

    http://oshiete1.goo.ne.jp/qa3200000.html 上記を参考にみましたが、どうしても解決できないので教えてください。 質問内容も同じくWindowsでEthnaを使おうとしていますが、プロジェクトをWebに公開することができません。 ブラウザに下記のような表記が出ます。 ****************************************************************** Warning: main(Ethna/Ethna.php) [function.main]: failed to open stream: No such file or directory in C:\home\ethna\public_html\sample\app\Sample_Controller.php on line 20 Fatal error: main() [function.require]: Failed opening required 'Ethna/Ethna.php' (include_path='.:/usr/local/lib/php/Smarty;C:\home\ethna\public_html\sample/app;C:\home\ethna\public_html\sample/lib') in C:\home\ethna\public_html\sample\app\Sample_Controller.php on line 20 ****************************************************************** ディレクトリ構造は C:\ -- php\ -- PEAR\ -- Ethna、smarty、PEAR等 プロジェクトは C:\   home\ -- ethna\ -- public_html\ -- sample の中に入っており http://localhost/~ethna/sample/www/index.php にアクセスしています。 パスの指定が間違っているのだと思いますが どうしても解決できません。 アドバイスお願いします。

    • 締切済み
    • PHP
  • Ethnaの基本設定について

    はじめまして。Ethnaに関して質問したいことがあります。 現在WindowsでEthnaの環境設定をしているのですが、プロジェクトをWebに公開することができません。 ディレクトリ構造は C:\  php\ -- PEAR\ -- Ethna、smarty、PEAR等 programfile\ -- apache\ -- htdocs\ -- wwwディレクトリ内のコピー sample(プロジェクト)\ -- app -- www ・         ・ でhttp://localhost/sampleにアクセスしてもページが表示されません。 php.iniのinclude_pathはC:\php\PEARです。 リンクがうまくいってないのかと思うのですがどうしたらよいかわかりません。 Ethnaに詳しい方ご教授お願いいたします。

    • ベストアンサー
    • PHP
  • smartyテンプレート読み込みについて

    Smarty動的Webサイト構築入門という書籍を見ながらSmartyを学習しているのですが、書籍のCD-ROMから落としたサンプルファイルを保存しているのですがどうしてもテンプレートを読み込むことができません。 03_01.php <?php require_once("../smarty/libs/Smarty.class.php"); $smarty = new Smarty(); $smarty->template_dir = "templates"; $smarty->compile_dir = "templates_c"; $smarty->assign("name", "Smartyさん"); $smarty->display("03_01.tpl"); ?> 03_01.tpl Hello, {$name}!! エラーメッセージ Warning: Smarty error: unable to read resource: "03_01.tpl" in C:\xampp\htdocs\smartybook\smarty\libs\Smarty.class.php on line 1092 03_01.phpは、C:\xampp/htdocs/smartybook/ren/に保存しています。 03_01.tplは、C:\xampp/htdocs/smartybook/templates/に保存しています。 どこが駄目なのか教えてください。 宜しくお願いします。

    • 締切済み
    • PHP
  • 特殊な連想配列について

    どなたか教えてください。 $_REQUESTを使用した部分に警告が出て正しく表示されません。 参考にしたサンプルソースの説明書にはPHP5.2.6と書いてあったのですが、 私の環境は5.3ですのでそれが起因しているような気がするのですが、ググっても 全くわかりません。 if($_REQUEST(["xxx"]) != "" ) のような記述部分が全て Notice: Undefined index: xxx in C:\xampp\htdocs\abcde\test.php on line 49 のようになります。 よろしくお願いいたします。

    • ベストアンサー
    • PHP
  • いつもお世話になっております。

    いつもお世話になっております。 小生、只今WindowsXPSP3上でXAMPP1.7.1を使用し、PHPを勉強しているPHP初心者です。 今回皆様にご質問させて頂きたい内容はXAMPPにSmatyをインストールするべきかしないべきかです。 私の環境でXAMPPのフォルダ内で「smarty」というキーワードを入れ、検索してみたところ、以下のファイルが検出されました。 smarty ディレクトリ     C:\xampp\htdocs\xoops\class Smarty.class.php       C:\xampp\htdocs\xoops\class\smarty Smarty_Compiler.class.php   C:\xampp\htdocs\xoops\class\smarty Smarty-2.6.0 ディレクトリ  C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor core.assign_smarty_interface.php C:\xampp\htdocs\xoops\class\smarty\core core.smarty_include_php.php  C:\xampp\htdocs\xoops\class\smarty\core SmartyTask.php C:\xampp\php\PEAR\phing\tasks\ext smarty ディレクトリ C:\xampp\htdocs\extras\extra_languages\pt_utf8\html\class Smarty ディレクトリ C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Converters\HTML Smarty.class.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs Smarty_Compiler.class.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs HTMLSmartyConverter.inc C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Converters\HTML\Smarty core.assign_smarty_interface.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs\core core.smarty_include_php.php C:\xampp\php\PEAR\PhpDocumentor\phpDocumentor\Smarty-2.6.0\libs\core 以上のファイルがあっても、XAMPPにSmartyをインストールしなければ、Smartyの機能は使えないのでしょうか?? また、上記の設定(Smartyをインストールしていない状態)でC:\xampp\sample\templatesフォルダを作成し、以下の.tplファイルを作成しました。 -----.tplファイル------ <html> <head> <title>smatyのテスト</title> </head> <body> ようこそ、($name)さん<br/> Hello World! </body> </html> そしてその上位フォルダにindex.phpを作成しました。 -----index.php----- <?php require_once "Smarty.class.php"; $smarty = new Smarty; $smarty->assign('name', '桃太郎'); $smarty->;display('index.tpl'); ?> 上記の2ファイルを作成し、http://localhost/sampleにアクセスしても、 「Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in C:\xampp\htdocs\sample\index.php on line 6」のエラーが出現し、正確に表示されません。 お忙しい中、大変申し訳ございませんが、先輩方アドバイス宜しくお願い致します。

    • ベストアンサー
    • PHP
  • 会員管理システムを作っているのですが、エラーが出て困っています。

    phpとsmartyで会員管理システムを構築しているのですが、以下のようなエラーが出て困っています。 エラー文 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Login.class.php:1) in C:\xampp\htdocs\login.php on line 5 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\Login.class.php:1) in C:\xampp\htdocs\login.php on line 5 Warning: Smarty error: unable to read resource: "login.tpl" in C:\xampp\htdocs\Smarty.class.php on line 1092 このエラー文は何と言っているのですか? また、解決方法が分かる方、ご回答お願いします。

    • 締切済み
    • PHP
  • PHPでのmail送信に関して

    教えて下さい。 PHPの中で、mail関数を用いてメール送信をしたいと考えていますが、 下記のようなエラーでどうしても送信できません。 Warning: mail() [function.mail]: SMTP server response: 999 5.7.1 Unable to relay for xxx.xxx@xxx.co.jp in C:\Apache Group\Apache2\htdocs\PHP\mail.php on line 9 phpの方の記述は、 <?php $to = 'xxx.xxx@xxx.co.jp'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: xxx.xxx@xxx.co.jp' . "\r\n" . 'Reply-To: xxx.xxx@xxx.co.jp' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> としてあります。 php.iniの部分も以下のように変更しています。 [mail function] ; For Win32 only. SMTP =xxx.xxx-mail.ne.jp ← ここをSMTPのメールサーバにしてあります。 ; For Win32 only. ; sendmail_from = ; For Unix only. You may supply arguments as well (default: 'sendmail -t -i'). ;sendmail_path = エラーを解除する為にはどこを修正すれば良いでしょうか。。。 教えて下さい。 宜しくお願いします。

    • 締切済み
    • PHP
  • ローカル環境でのメール送信

    PHP超初心者です。 ローカル環境でmb_send_mail関数をつかってメール送信をしたいのです が、上手くいきません。 エラーメッセージは Warning: mb_send_mail() [function.mb-send-mail]: SMTP server response: 530 5.7.0 Must issue a STARTTLS command first n44sm11126503pyh in C:\xampp\htdocs\○○○\○○.php on line 15 とでています。 文字コードはUTF-8で保存しており、 <?php mb_language("ja"); mb_internal_encoding("UTF-8"); $mailto="○○○@○○○.jp"; $subject="タイトル"; $content="内容"; $mailfrom="From:".mb_encode_mimeheader("nicoko")."<○○○@フリーメールアドレス.com>"; mb_send_mail($mailto,$subject,$content,$mailfrom); ?> です。 15行目はmb_send_mail($mailto,$subject,$content,$mailfrom); 色々調べたところ、 (1)SMTP = メールアドレス用のsmtpサーバの設定 (2)smtp_port = 25 (3)sendmail_from = メールアドレス を設定しなおし、 C:\xampp\apache\bin\php.ini C:\xampp\php\php.ini C:\xampp\php\php5.ini C:\xampp\php\php4\php.ini 全ての設定を変更しました。 またphpinfoで確認したところ(1)~(3)まで変更されていました。 (3)はOutlookのメールのアカウント→プロパティを見て サーバー情報→送信メールに○○.○○○.jpと書いてあり、 それをうつしました。 宜しくお願いします。

    • ベストアンサー
    • PHP
  • gmailAPIのサンプルプログラムの問題

    現在、gmailAPIのPHP版を使って、gmailに送信されたメール情報を 取得しようとしています。 https://developers.google.com/gmail/api/quickstart/php 上記サイトの通りにAPIキーを取得し、APIキーと同じ場所に、 サンプルプログラムであるquickstart.phpというデータを、 text.phpという名前で実行したところ、XAMPP上では下記のような エラーメッセージが出てしまいます。 This application must be run on the command line. Fatal error: Uncaught Error: Class 'Google_Client' not found in C:\xampp\htdocs\Twitter\text.php:16 Stack trace: #0 C:\xampp\htdocs\Twitter\text.php(62): getClient() #1 {main} thrown in C:\xampp\htdocs\Twitter\text.php on line 16 コマンドラインの部分は意味が分かったのですが、Google_Clientというクラスは、 元のquickstart.phpにも記載はありませんし、こちらがミスしているとも思えません。 現在、githubでも質問してみているのですが、英語サイトのため、わかりづらくて こちらでも投げてみました。 どなたか、わかる方がいたら、至急お助けいただけないでしょうか?

    • ベストアンサー
    • PHP
  • メール送信に関して

    教えて下さい。 登録画面を用意し、そこに入力されたEメールアドレス宛に、登録ボタン を押した時点で返信メールが送られるような仕組みを作成したいと考えて おります。 調べてみましたが、mail関数機能を使用すればと記載されていましたが、 実際にどのように記述するのかわかりません・・・。 サンプルでは下記のような設定をするとありましたが、それぞれ具体的に どのような設定をすれば良いでしょうか?  mail(smtp,smtp_port,sendmail_from,sendmail_path) また、ある程度めぼしを付けて作成し、サンプルを設定して実行したところ、 下記のようなエラーが表示されました。 何がおかしいのでしょうか。。。。 Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\Apache Group\Apache2\htdocs\XXXX\sendmail.php on line 172 どなたかわかる方、ご教授下さい。 よろしくお願いします。

    • 締切済み
    • PHP

専門家に質問してみよう