3 * Send an Email Message Page
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * The rest Copyright 2002-2004 (c) GForge Team
9 * This file is part of GForge.
11 * GForge is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * GForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with GForge; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 require_once('./env.inc.php');
27 require_once $gfwww.'include/pre.php';
29 $toaddress = getStringFromRequest('toaddress');
30 $touser = getStringFromRequest('touser');
32 if (!$toaddress && !$touser) {
33 exit_error(_('Error'),_('Error - some variables were not provided'));
38 check to see if that user even exists
39 Get their name and email if it does
41 $result=db_query_params ('SELECT email,user_name FROM users WHERE user_id=$1',
44 if (!$result || db_numrows($result) < 1) {
45 exit_error(_('Error'),_('Error - That user does not exist'));
49 if ($toaddress && !eregi($GLOBALS['sys_default_domain'],$toaddress)) {
50 exit_error(_('Error'),sprintf(_('You can only send to addresses @<em>%1$s</em>.'),$GLOBALS['sys_default_domain']));
54 if (getStringFromRequest('send_mail')) {
55 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
56 exit_form_double_submit();
59 $subject = getStringFromRequest('subject');
60 $body = getStringFromRequest('body');
61 $name = getStringFromRequest('name');
62 $email = getStringFromRequest('email');
64 if (!$subject || !$body || !$name || !$email) {
66 force them to enter all vars
68 form_release_key(getStringFromRequest('form_key'));
72 // we remove the CRLF in all thoses vars. This is to make sure that there will be no CRLF Injection
73 $name = util_remove_CRLF($name);
74 // Really don't see what wrong could happen with CRLF in message body
75 //$email = util_remove_CRLF($email);
76 $subject = util_remove_CRLF($subject);
80 send it to the toaddress
82 $to=eregi_replace('_maillink_','@',$toaddress);
83 $to = util_remove_CRLF($to);
84 util_send_message($to,stripslashes($subject),stripslashes($body),$email,'',$name);
85 $HTML->header(array('title'=>forge_get_config ('forge_name').' ' ._('Contact') ));
86 echo '<p>'._('Message has been sent').'.</p>';
87 $HTML->footer(array());
91 figure out the user's email and send it there
93 $to=db_result($result,0,'email');
94 $to = util_remove_CRLF($to);
95 util_send_message($to,stripslashes($subject),stripslashes($body),$email,'',$name);
96 $HTML->header(array('title'=>forge_get_config ('forge_name').' '._('Contact')));
97 echo '<p>'._('Message has been sent').'</p>';
98 $HTML->footer(array());
104 $titleaddress = $toaddress;
106 $titleaddress = db_result($result,0,'user_name');
109 if (session_loggedin()) {
110 $user =& session_get_user();
111 $name = $user->getRealName();
112 $email = $user->getEmail();
117 $subject = getStringFromRequest('subject');
119 $HTML->header(array('title'=>forge_get_config ('forge_name').' Staff'));
124 <?php echo _('In an attempt to reduce spam, we are using this form to send email.<p />Fill it out accurately and completely or the receiver may not be able to respond.<p /><span class="important"><b>IF YOU ARE WRITING FOR HELP:</b> Did you read the site documentation? Did you include your <b>user_id</b> and <b>user_name?</b> If you are writing about a project, include your <b>project id</b> (<b>group_id</b>) and <b>Project Name</b>.</span>'); ?>
126 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post">
127 <input type="hidden" name="form_key" value="<?php echo form_generate_key(); ?>" />
128 <input type="hidden" name="toaddress" value="<?php echo $toaddress; ?>" />
129 <input type="hidden" name="touser" value="<?php echo $touser; ?>" />
131 <strong><?php echo _('Your Name').utils_requiredField() ?> :</strong><br />
132 <input type="text" name="name" size="40" maxlength="40" value="<?php echo $name ?>" />
134 <strong><?php echo _('Your Email Address').utils_requiredField() ?> :</strong><br />
135 <input type="text" name="email" size="40" maxlength="255" value="<?php echo $email ?>" />
137 <strong><?php echo _('Subject').utils_requiredField() ?> :</strong><br />
138 <input type="text" name="subject" size="60" maxlength="255" value="<?php echo $subject; ?>" />
140 <strong><?php echo _('Message').utils_requiredField() ?> :</strong><br />
141 <textarea name="body" rows="15" cols="60"></textarea>
144 <input type="submit" name="send_mail" value="<?php echo _('Send Message') ?>" />
148 $HTML->footer(array());
152 // c-file-style: "bsd"