-<?
+<?php
/** This code sends a mail.
**
** There are 3 modes of operation:
** - Send mail
**/
+ session_start();
+
if (!isset($config_php))
include("../config/config.php");
if (!isset($strings_php))
include("../src/load_prefs.php");
- echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
- $imapConnection = sqimap_login($username, $key, $imapServerAddress, 0);
- displayPageHeader($color, "None");
-
// This function is used when not sending or adding attachments
function newMail () {
global $forward_id, $imapConnection, $msg, $ent_num, $body_ary, $body,
}
}
- $send_to = sqimap_find_email($send_to);
-
+ if (!$send_to) {
+ $send_to = sqimap_find_email($send_to);
+ }
+
$send_to = ereg_replace("\"", "", $send_to);
$send_to = stripslashes($send_to);
$reply_subj = decodeHeader($reply_subj);
$forward_subj = decodeHeader($forward_subj);
- echo "\n<FORM action=\"compose.php\" METHOD=POST\n";
+ echo "\n<SCRIPT LANGUAGE=JavaScript><!--\n";
+ echo "function open_abook() { \n";
+ echo " var nwin = window.open(\"addrbook_popup.php\",\"abookpopup\",";
+ echo "\"width=670,height=300,resizable=yes,scrollbars=yes\");\n";
+ echo " if((!nwin.opener) && (document.windows != null))\n";
+ echo " nwin.opener = document.windows;\n";
+ echo "}\n";
+ echo "// --></SCRIPT>\n\n";
+
+ echo "\n<FORM name=compose action=\"compose.php?\" METHOD=POST\n";
echo "ENCTYPE=\"multipart/form-data\">\n";
echo "<TABLE COLS=2 WIDTH=50 ALIGN=center CELLSPACING=0 BORDER=0>\n";
echo " <TR>\n";
echo " <INPUT TYPE=TEXT NAME=send_to_bcc SIZE=60><BR>";
echo " </TD>\n";
echo " </TR>\n";
+
+ echo "<SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
+ echo "<TR><TD BGCOLOR=\\\"$color[4]\\\"> </TD>";
+ echo "</TD><TD BGCOLOR=\\\"$color[4]\\\" ALIGN=LEFT>";
+ printf("<A HREF=\\\"javascript:open_abook();\\\">%s</A>",
+ _("Lookup recipients in addressbook.")."<BR>");
+ echo "</TD></TR>\");\n";
+ echo "// --></SCRIPT>\n";
+
echo " <TR>\n";
echo " <TD WIDTH=50 BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
echo _("Subject:");
echo "</CENTER>";
}
- function checkInput () {
- global $body, $send_to, $subject;
+ function checkInput ($show) {
+ /** I implemented the $show variable because the error messages
+ were getting sent before the page header. So, I check once
+ using $show=false, and then when i'm ready to display the
+ error message, show=true **/
+ global $body, $send_to, $subject, $color;
if ($body == "") {
- plain_error_message(_("You have not entered a message body."), $color);
+ if ($show)
+ plain_error_message(_("You have not entered a message body."), $color);
return false;
} else if ($send_to == "") {
- displayPageHeader($color, "None");
- plain_error_message(_("You have not filled in the \"To:\" field."), $color);
+ if ($show)
+ plain_error_message(_("You have not filled in the \"To:\" field."), $color);
return false;
} else if ($subject == "") {
- plain_error_message(_("You have not entered a subject."), $color);
+ if ($show)
+ plain_error_message(_("You have not entered a subject."), $color);
return false;
}
return true;
} // function checkInput()
if(isset($send)) {
- if (checkInput()) {
+ if (checkInput(false)) {
sendMessage($send_to, $send_to_cc, $send_to_bcc, $subject, $body);
- showSentForm();
+ header ("Location: right_main.php");
} else {
+ echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+ displayPageHeader($color, "None");
+ checkInput(true);
+
showInputForm();
}
} else if (isset($attach)) {
+ echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+ displayPageHeader($color, "None");
+
$localfilename = md5("$attachfile, $attachfile_name, $REMOTE_IP, $REMOTE_PORT, $UNIQUE_ID, and everything else that may add entropy");
$localfilename = $localfilename;
showInputForm();
} else if (isset($do_delete)) {
+ echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+ displayPageHeader($color, "None");
+
while (list($key, $localname) = each($delete)) {
array_splice ($attachments, $key, 1);
unlink ($attachment_dir.$localname);
showInputForm();
} else {
+ echo "<HTML><BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n";
+ $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
+ displayPageHeader($color, "None");
+
$newmail = true;
newMail();
showInputForm();