4 * mailto.php -- mailto: url handler
6 * This checks to see if we're logged in. If we are we open up a new
7 * compose window for this email, otherwise we go to login.php
8 * (the above functionality has been disabled, by default you are required to
11 * Use the following url to use mailto:
12 * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress=%1
13 * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file
14 * @copyright © 1999-2006 The SquirrelMail Project Team
15 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
17 * @package squirrelmail
20 // reduce the included files in int.php
24 * Include the SquirrelMail initialization file.
26 require('../include/init.php');
28 /* Force users to login each time? */
30 /* Open only the compose window, meaningless if $force_login is true */
31 $compose_only = false;
33 header('Pragma: no-cache');
35 $trtable = array('cc' => 'send_to_cc',
36 'bcc' => 'send_to_bcc',
38 'subject' => 'subject');
41 if(sqgetGlobalVar('emailaddress', $emailaddress)) {
42 $emailaddress = trim($emailaddress);
43 if(stristr($emailaddress, 'mailto:')) {
44 $emailaddress = substr($emailaddress, 7);
46 if(strpos($emailaddress, '?') !== false) {
47 list($emailaddress, $a) = explode('?', $emailaddress, 2);
48 if(strlen(trim($a)) > 0) {
49 $a = explode('=', $a, 2);
50 $url .= $trtable[strtolower($a[0])] . '=' . urlencode($a[1]) . '&';
53 $url = 'send_to=' . urlencode($emailaddress) . '&' . $url;
55 /* CC, BCC, etc could be any case, so we'll fix them here */
56 foreach($_GET as $k=>$g) {
58 if(isset($trtable[$k])) {
60 $url .= $k . '=' . urlencode($g) . '&';
63 $url = substr($url, 0, -1);
66 if($force_login == false && sqsession_is_registered('user_is_logged_in')) {
67 if($compose_only == true) {
68 $redirect = 'compose.php?' . $url;
70 $redirect = 'webmail.php?right_frame=compose.php?' . urlencode($url);
73 $redirect = 'login.php?mailto=' . urlencode($url);
76 session_write_close();
77 header('Location: ' . get_location() . '/' . $redirect);