Basic mailto: support.
[squirrelmail.git] / src / mailto.php
... / ...
CommitLineData
1<?php
2
3/**
4 * mailto.php -- mailto: url handler
5 *
6 * Copyright (c) 1999-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This checks to see if we're logged in. If we are we open up a new
10 * compose window for this email, otherwise we go to login.php
11 * (the above functionality has been disabled, by default you are required to
12 * login first)
13 *
14 * Use the following url to use mailto:
15 * http://<your server>/<squirrelmail base dir>/src/mailto.php?emailaddress="%1"
16 * see ../contrib/squirrelmail.mailto.reg for a Windows Registry file
17 */
18
19/* Path for SquirrelMail required files. */
20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
23require_once(SM_PATH . 'config/config.php');
24require_once(SM_PATH . 'functions/global.php');
25
26header('Pragma: no-cache');
27if(!sqgetGlobalVar('emailaddress', $emailaddress)) {
28 return;
29}
30
31if(stristr($emailaddress, 'mailto:')) {
32 $emailaddress = substr($emailaddress, 7);
33}
34if(($pos = strpos($emailaddress, '?')) !== false) {
35 $a = substr($emailaddress, $pos+1);
36 list($emailaddress, $a) = explode('?', $emailaddress, 2);
37 $a = explode('=', $a, 2);
38 $_GET['emailaddress'] = $emailaddress;
39 $_GET[$a[0]] = $a[1];
40}
41
42$trtable = array('emailaddress' => 'send_to',
43 'cc' => 'send_to_cc',
44 'bcc' => 'send_to_bcc',
45 'body' => 'body',
46 'subject' => 'subject');
47$url = '';
48/* CC, BCC, etc could be any case, so we'll fix them here */
49foreach($_GET as $k=>$g) {
50 if($g != '') {
51 $k = strtolower($k);
52 $k = $trtable[$k];
53 $url .= $k . '=' . urlencode($g) . '&';
54 }
55}
56$url = substr($url, 0, -1);
57
58sqsession_is_active();
59/* Check to see if we're logged in */
60/*
61if (sqsession_is_registered('user_is_logged_in')) {
62 $redirect = 'webmail.php?right_frame=compose.php?';
63} else {
64 $redirect = 'login.php?mailto=';
65}
66*/
67$url = urlencode($url);
68/* $redirect .= $url; */
69$redirect = 'login.php?mailto=' . $url;
70session_write_close();
71header('Location: ' . $redirect);
72?>