| | |
| | | /****** checks ********/ |
| | | |
| | | if (!isset($_SESSION['compose']['id'])) { |
| | | raise_error(array('code' => 500, 'file' => __FILE__, 'message' => "Invalid compose ID"), true, false); |
| | | raise_error(array('code' => 500, 'type' => 'smtp', 'file' => __FILE__, 'message' => "Invalid compose ID"), true, false); |
| | | console("Sendmail error", $_SESSION['compose']); |
| | | $OUTPUT->show_message("An internal error occured. Please try again.", 'error'); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | |
| | | if (!$savedraft && empty($_POST['_to']) && empty($_POST['_cc']) && empty($_POST['_bcc']) && empty($_POST['_subject']) && $_POST['_message']) { |
| | | $OUTPUT->show_message('sendingfailed', 'error'); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | |
| | | if(!$savedraft && !empty($CONFIG['sendmail_delay'])) { |
| | | $wait_sec = time() - intval($CONFIG['sendmail_delay']) - intval($_SESSION['last_message_time']); |
| | | if($wait_sec < 0) |
| | | { |
| | | $OUTPUT->show_message('senttooquickly', 'error', array('sec' => $wait_sec * -1)); |
| | | if (!$savedraft) { |
| | | if (empty($_POST['_to']) && empty($_POST['_cc']) && empty($_POST['_bcc']) |
| | | && empty($_POST['_subject']) && $_POST['_message']) { |
| | | $OUTPUT->show_message('sendingfailed', 'error'); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | |
| | | if(!empty($CONFIG['sendmail_delay'])) { |
| | | $wait_sec = time() - intval($CONFIG['sendmail_delay']) - intval($CONFIG['last_message_time']); |
| | | if($wait_sec < 0) { |
| | | $OUTPUT->show_message('senttooquickly', 'error', array('sec' => $wait_sec * -1)); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | $out = $sql_arr; |
| | | $out['mailto'] = $sql_arr['email']; |
| | | $name = strpos($sql_arr['name'], ",") ? '"'.$sql_arr['name'].'"' : $sql_arr['name']; |
| | | $out['string'] = sprintf('%s <%s>', |
| | | rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()), |
| | | $sql_arr['email']); |
| | | |
| | | // Special chars as defined by RFC 822 need to in quoted string (or escaped). |
| | | if (preg_match('/[\(\)\<\>\\\.\[\]@,;:"]/', $sql_arr['name'])) |
| | | $name = '"' . addcslashes($sql_arr['name'], '"') . '"'; |
| | | else |
| | | $name = $sql_arr['name']; |
| | | |
| | | $out['string'] = rcube_charset_convert($name, RCMAIL_CHARSET, $OUTPUT->get_charset()); |
| | | if ($sql_arr['email']) |
| | | $out['string'] .= ' <' . $sql_arr['email'] . '>'; |
| | | |
| | | return $out; |
| | | } |
| | | |
| | |
| | | $body = preg_replace('/\x00/', '', $htmlContents); |
| | | |
| | | $last_img_pos = 0; |
| | | |
| | | $searchstr = 'program/js/tiny_mce/plugins/emotions/img/'; |
| | | $path_len = strlen(INSTALL_PATH . '/'); |
| | | |
| | | // keep track of added images, so they're only added once |
| | | $included_images = array(); |
| | |
| | | { |
| | | $pos2 = strpos($body, '"', $pos); |
| | | $body_pre = substr($body, 0, $pos); |
| | | $body_post = substr($body, $pos2); |
| | | |
| | | $image_name = substr($body, |
| | | $pos + strlen($searchstr), |
| | | $pos2 - ($pos + strlen($searchstr))); |
| | | |
| | | // sanitize image name so resulting attachment doesn't leave images dir |
| | | $image_name = preg_replace('/[^a-zA-Z0-9_\.\-]/i','',$image_name); |
| | | |
| | | $body_post = substr($body, $pos2); |
| | | $img_file = INSTALL_PATH . '/' . $searchstr . $image_name; |
| | | |
| | | if (! in_array($image_name, $included_images)) |
| | | { |
| | | // add the image to the MIME message |
| | | $img_file = INSTALL_PATH . '/' . $searchstr . $image_name; |
| | | if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name)) |
| | | $OUTPUT->show_message("emoticonerror", 'error'); |
| | | |
| | | array_push($included_images, $image_name); |
| | | } |
| | | |
| | | |
| | | $body = $body_pre . $img_file . $body_post; |
| | | |
| | | $last_img_pos = $pos2; |
| | | $last_img_pos = $pos2 + $path_len; |
| | | } |
| | | |
| | | |
| | | $mime_message->setHTMLBody($body); |
| | | } |
| | | |
| | |
| | | $input_charset = $OUTPUT->get_charset(); |
| | | $message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset; |
| | | |
| | | $mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/'); |
| | | $mailto_replace = array(', ', ', ', '', ','); |
| | | $mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/', '/(\S{1})(<\S+@\S+>)/U'); |
| | | $mailto_replace = array(', ', ', ', '', ',', '\\1 \\2'); |
| | | |
| | | // replace new lines and strip ending ', ' |
| | | // replace new lines and strip ending ', ', make address strings more valid also |
| | | $mailto = preg_replace($mailto_regexp, $mailto_replace, get_input_value('_to', RCUBE_INPUT_POST, TRUE, $message_charset)); |
| | | $mailcc = preg_replace($mailto_regexp, $mailto_replace, get_input_value('_cc', RCUBE_INPUT_POST, TRUE, $message_charset)); |
| | | $mailbcc = preg_replace($mailto_regexp, $mailto_replace, get_input_value('_bcc', RCUBE_INPUT_POST, TRUE, $message_charset)); |
| | |
| | | $mailto = 'undisclosed-recipients:;'; |
| | | |
| | | // get sender name and address |
| | | $identity_arr = rcmail_get_identity(get_input_value('_from', RCUBE_INPUT_POST)); |
| | | $from = $identity_arr['mailto']; |
| | | $from = get_input_value('_from', RCUBE_INPUT_POST); |
| | | $identity_arr = rcmail_get_identity($from); |
| | | |
| | | if ($identity_arr) |
| | | $from = $identity_arr['mailto']; |
| | | |
| | | if (empty($identity_arr['string'])) |
| | | $identity_arr['string'] = $from; |
| | |
| | | // empty message body breaks attachment handling in drafts |
| | | $plainTextPart = "\r\n"; |
| | | } |
| | | $MAIL_MIME->setTXTBody(html_entity_decode($plainTextPart, ENT_COMPAT, 'utf-8')); |
| | | $MAIL_MIME->setTXTBody($plainTextPart); |
| | | |
| | | // look for "emoticon" images from TinyMCE and copy into message as attachments |
| | | rcmail_attach_emoticons($MAIL_MIME); |
| | |
| | | $attachment['name'], true, |
| | | ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), |
| | | ($ctype == 'message/rfc822' ? 'inline' : 'attachment'), |
| | | $message_charset); |
| | | $message_charset, '', '', |
| | | $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL, |
| | | $CONFIG['mime_param_folding'] == 2 ? 'quoted-printable' : NULL |
| | | ); |
| | | } |
| | | } |
| | | |
| | |
| | | $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914 |
| | | |
| | | $MAIL_MIME->addAttachment($filepath, $ctype, $files['name'][$i], true, |
| | | ($ctype == 'message/rfc822' ? $transfer_encoding : 'base64'), |
| | | 'attachment', $message_charset); |
| | | $ctype == 'message/rfc822' ? $transfer_encoding : 'base64', |
| | | 'attachment', $message_charset, '', '', |
| | | $CONFIG['mime_param_folding'] ? 'quoted-printable' : NULL, |
| | | $CONFIG['mime_param_folding'] == 2 ? 'quoted-printable' : NULL |
| | | ); |
| | | } |
| | | |
| | | |
| | |
| | | // Begin SMTP Delivery Block |
| | | if (!$savedraft) |
| | | { |
| | | // check for 'From' address (identity may be incomplete) |
| | | if ($identity_arr && !$identity_arr['mailto']) { |
| | | $OUTPUT->show_message('nofromaddress', 'error'); |
| | | $OUTPUT->send('iframe'); |
| | | } |
| | | |
| | | $sent = rcmail_deliver_message($MAIL_MIME, $from, $mailto); |
| | | |
| | | // return to compose page if sending failed |
| | |
| | | |
| | | // save message sent time |
| | | if (!empty($CONFIG['sendmail_delay'])) |
| | | $_SESSION['last_message_time'] = time(); |
| | | $RCMAIL->user->save_prefs(array('last_message_time' => time())); |
| | | |
| | | // set replied/forwarded flag |
| | | if ($_SESSION['compose']['reply_uid']) |
| | |
| | | if ($olddraftmessageid) |
| | | { |
| | | // delete previous saved draft |
| | | $a_deleteid = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID', $olddraftmessageid); |
| | | $a_deleteid = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$olddraftmessageid); |
| | | |
| | | $deleted = $IMAP->delete_message($IMAP->get_uid($a_deleteid[0], $CONFIG['drafts_mbox']), $CONFIG['drafts_mbox']); |
| | | |
| | | // raise error if deletion of old draft failed |
| | |
| | | $msgid = strtr($message_id, array('>' => '', '<' => '')); |
| | | |
| | | // remember new draft-uid |
| | | $draftids = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID', $msgid); |
| | | $draftids = $IMAP->search($CONFIG['drafts_mbox'], 'HEADER Message-ID '.$msgid); |
| | | $_SESSION['compose']['param']['_draft_uid'] = $IMAP->get_uid($draftids[0], $CONFIG['drafts_mbox']); |
| | | |
| | | // display success |