require_once(SM_PATH . 'functions/imap.php');
require_once(SM_PATH . 'functions/date.php');
require_once(SM_PATH . 'functions/mime.php');
-//require_once(SM_PATH . 'functions/smtp.php');
require_once(SM_PATH . 'functions/plugin.php');
require_once(SM_PATH . 'functions/display_messages.php');
require_once(SM_PATH . 'class/deliver/Deliver.class.php');
$composesession = $_SESSION['composesession'];
}
sqextractGlobalVar('action');
-sqextractGlobalVar('send');
sqextractGlobalVar('session');
sqextractGlobalVar('mailbox');
sqextractGlobalVar('identity');
sqextractGlobalVar('mail_sent');
sqextractGlobalVar('passed_id');
sqextractGlobalVar('passed_ent_id');
+sqextractGlobalVar('send');
if ( isset($_POST['sigappend']) ) {
$sigappend = $_POST['sigappend'];
if ( isset($_POST['delete']) ) {
$delete = &$_POST['delete'];
}
-if ( isset($_POST['attachments']) ) {
- $attachments = &$_POST['attachments'];
-}
-elseif ( isset($_SESSION['attachments'])) {
- $attachments = &$_SESSION['attachments'];
+if ( isset($_SESSION['compose_messages']) ) {
+ $compose_messages = &$_SESSION['compose_messages'];
}
+
/* Forward message as attachment */
if ( isset($_GET['attachedmessages']) ) {
$attachedmessages = $_GET['attachedmessages'];
* vars.
*/
//$session_expired = false;
-if (session_is_registered('session_expired_post')) {
+sqsession_unregister('session_expired_post');
+if (false && session_is_registered('session_expired_post')) {
global $session_expired_post, $session_expired;
/*
* extra check for username so we don't display previous post data from
if (!isset($mailbox)) {
$mailbox = '';
}
+
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
} else {
showInputForm($session, false);
exit();
}
-
if (!isset($composesession)) {
$composesession = 0;
sqsession_register(0,'composesession');
$mailbox = 'INBOX';
}
-if (isset($draft)) {
- /*
- * Set $default_charset to correspond with the user's selection
- * of language interface.
- */
- set_my_charset();
- $composeMessage=$compose_messages[$session];
- $Result = sendMessage($composeMessage, true);
-
+if ($draft) {
+ /*
+ * Set $default_charset to correspond with the user's selection
+ * of language interface.
+ */
+ set_my_charset();
+ $composeMessage=$compose_messages[$session];
if (! sendMessage($composeMessage, true)) {
showInputForm($session);
exit();
}
}
-if (isset($send)) {
+if ($send) {
if (isset($_FILES['attachfile']) &&
$_FILES['attachfile']['tmp_name'] &&
$_FILES['attachfile']['tmp_name'] != 'none') {
"&startMessage=1");
}
} else {
- /*
- *$imapConnection = sqimap_login($username, $key, $imapServerAddress,
- * $imapPort, 0);
- */
if ($compose_new_win == '1') {
compose_Header($color, $mailbox);
}
/* this corrects some wrapping/quoting problems on replies */
$rewrap_body = explode("\n", $body);
- $body = getReplyCitation($orig_header->from->personal);
+ $from = (is_array($orig_header->from)) ?
+ $orig_header->from[0] : $orig_header->from;
+ $body = getReplyCitation($from->getAddress(false));
+
$cnt = count($rewrap_body);
for ($i=0;$i<$cnt;$i++) {
- // sqWordWrap($rewrap_body[$i], ($editor_size - 2));
+// sqWordWrap($rewrap_body[$i], ($editor_size - 2));
if (preg_match("/^(>+)/", $rewrap_body[$i], $matches)) {
$gt = $matches[1];
$body .= '>' . str_replace("\n", "\n$gt ", $rewrap_body[$i]) ."\n";
echo "\n" . '<FORM name=compose action="compose.php" METHOD=POST ' .
'ENCTYPE="multipart/form-data"';
do_hook("compose_form");
-
echo ">\n";
if ($location_of_buttons == 'between') {
showComposeButtonRow();
}
+
if ($compose_new_win == '1') {
echo ' <TR>' . "\n" .
' <TD BGCOLOR="' . $color[0] . '" COLSPAN=2 ALIGN=CENTER>' . "\n" .
$s_a = array();
- foreach ($composeMessage->entities as $key => $attachment) {
+ if ($composeMessage->entities) {
+ foreach ($composeMessage->entities as $key => $attachment) {
$attached_file = $attachment->att_local_name;
if ($attachment->att_local_name || $attachment->body_part) {
$attached_filename = decodeHeader($attachment->mime_header->getParameter('name'));
' ('.show_readable_size( filesize( $attached_file ) )
. ')<br>'."\n";
}
+ }
}
if (count($s_a)) {
foreach ($s_a as $s) {
'<input type="hidden" name="username" value="'. $username . "\">\n" .
'<input type=hidden name=action value=' . $action . ">\n" .
'<INPUT TYPE=hidden NAME=mailbox VALUE="' . htmlspecialchars($mailbox) .
- "\">\n" .
- '</FORM>';
+ "\">\n";
+ echo '</FORM>';
do_hook('compose_bottom');
echo '</BODY></HTML>' . "\n";
}
echo '<input type="submit" name ="draft" value="' . _("Save Draft") . "\">\n";
}
- echo "\n <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
+ echo '<INPUT TYPE=submit NAME=send VALUE="'. _("Send") . "\">\n";
do_hook('compose_button_row');
echo " </TD></TR>\n\n";
$imap_stream = sqimap_login($username, $key, $imapServerAddress,
$imapPort, 0);
if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) {
- require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
- $imap_deliver = new Deliver_IMAP();
- $length = $imap_deliver->mail($composeMessage);
- sqimap_append ($imap_stream, $draft_folder, $length);
- $imap_deliver->mail($composeMessage, $imap_stream);
- sqimap_append_done ($imap_stream);
- sqimap_logout($imap_stream);
- unset ($imap_deliver);
-
+ require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
+ $imap_deliver = new Deliver_IMAP();
+ $length = $imap_deliver->mail($composeMessage);
+ sqimap_append ($imap_stream, $draft_folder, $length);
+ $imap_deliver->mail($composeMessage, $imap_stream);
+ sqimap_append_done ($imap_stream);
+ sqimap_logout($imap_stream);
+ unset ($imap_deliver);
+ return $length;
+ } else {
+ $msg = '<br>Error: '._("Draft folder")." $draft_folder" . ' does not exist.';
+ plain_error_message($msg, $color);
+ return false;
}
- return $length;
}
$succes = false;
if ($stream) {