3 * Copyright (C) 2003-2005 Polytechnique.org
4 * http://opensource.polytechnique.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 require_once 'Plugin/Filter.php';
22 require_once 'diogenes/diogenes.hermes.inc.php';
24 /** The MailForm plugin allows you to insert a form to send
25 * an e-mail to a fixed recipient.
27 * To make use of this plugin, insert {MailForm}in your page
28 * where the mail form should appear.
30 class MailForm
extends Diogenes_Plugin_Filter
33 var $name = "MailForm";
35 /** Plugin description */
36 var $description = "This plugin allows you to insert a form to send an e-mail to a fixed recipient. To make use of this plugin, insert <b>{MailForm}</b> in your page where the mail form should appear.";
38 /** Plugin parameters */
39 var $params = array('email' => '', 'title' => '', 'subject_tag' => '[web form] ');
41 /** Show an instance of the MailForm plugin.
48 $to_email = $this->params
['email'];
49 $form_title = $this->params
['title'];
51 if (!isvalid_email($to_email)) {
52 return '<p>You must specify a valid e-mail in the "email" parameter to make use of the MailForm plugin.<p>';
56 $action = clean_request('action');
57 $from = clean_request('from');
59 $refer = strip_request('refer');
61 $refer = $_SERVER['HTTP_REFERER'];
62 $message = strip_request('message');
63 $subject = strip_request('subject');
69 if ((!$subject)||
(!$message)||
(!$from)) {
70 $output .= '<p align="center"><strong>Missing fields !</strong></p>';
75 if (!isvalid_email($from)) {
76 $output .= '<p align="center"><strong>Invalid email address !</strong></p>';
81 $mymail = new HermesMailer();
82 $mymail->setFrom($from);
83 $mymail->setSubject($this->params
['subject_tag'].$subject);
84 $mymail->addTo($to_email);
85 $mymail->setTxtBody($message);
88 $output .= '<p align="center"><strong>Message sent !</strong></p>';
90 $output .= '<p align="center">To return to referring web page click <a href="'.$refer.'">here</a></p>';
101 <form action="'.$page->script_uri().'" method="post">
103 <table class="light">
105 <th colspan="2">'.$form_title.'</a></th>
108 <td>'.__("from").'</td>
109 <td><input type="text" name="from" size="68" value="'.$from.'" /></td>
112 <td>'.__("subject").'</td>
113 <td><input type="text" name="subject" size="68" value="'.$subject.'" /></td>
116 <td>'.__("message").'</td>
117 <td><textarea name="message" rows="10" cols="70">'.$message.'</textarea></td>
122 <input type="hidden" name="action" value="mail" />
123 <input type="hidden" name="refer" value="'.$refer.'" />
124 <input type="submit" value="'.__("Send").'"/>