* TO list) only if $include_self_reply_all is turned off
*/
if (!$include_self_reply_all) {
- $email_address = trim(getPref($data_dir, $username, 'email_address'));
+ $email_address = strtolower(trim(getPref($data_dir, $username, 'email_address')));
$excl_ar[$email_address] = '';
-
$idents = getPref($data_dir, $username, 'identities');
if ($idents != '' && $idents > 1) {
+ $first_id = false;
for ($i = 1; $i < $idents; $i ++) {
$cur_email_address = getPref($data_dir, $username,
'email_address' . $i);
- $cur_email_address = strtolower($cur_email_address);
- $excl_ar[$cur_email_address] = '';
+ $cur_email_address = strtolower(trim($cur_email_address));
+ $excl_ar[$cur_email_address] = '';
}
}
}
$url_replytoallcc = '';
foreach( $url_replytoall_ar as $email => $personal) {
if ($personal) {
- $url_replytoallcc .= ", \"$personal\" <$email>";
+ $url_replytoallcc .= ", \"$personal\" <$email>";
} else {
- $url_replytoallcc .= ', '. $email;
+ $url_replytoallcc .= ', '. $email;
}
}
$url_replytoallcc = substr($url_replytoallcc,2);
*/
set_my_charset();
$composeMessage=$compose_messages[$session];
- if (! sendMessage($composeMessage, true)) {
+ if (! deliverMessage($composeMessage, true)) {
showInputForm($session);
exit();
} else {
do_hook('compose_send');
$composeMessage=$compose_messages[$session];
- $Result = sendMessage($composeMessage);
+ $Result = deliverMessage($composeMessage);
if (! $Result) {
showInputForm($session);
exit();
$composeMessage->entities = $new_entities;
$compose_messages[$session] = $composeMessage;
sqsession_register($compose_messages, 'compose_messages');
-// setPref($data_dir, $username, 'attachments', serialize($attachments));
}
showInputForm($session);
} else {
} else {
$orig_from = '';
}
+ $identities = array();
if (!empty($idents) && $idents > 1) {
- for ($i = 1; $i < $idents; $i++) {
- $enc_from_name = '"'.
- getPref($data_dir,
- $username,
- 'full_name' . $i) .
- '" <' . getPref($data_dir, $username,
- 'email_address' . $i) . '>';
- if ($enc_from_name == $orig_from) {
+ $identities[] = '"'. getPref($data_dir, $username, 'full_name')
+ . '" <' . getPref($data_dir, $username, 'email_address') . '>';
+ for ($i = 1; $i < $idents; $i++) {
+ $enc_from_name = '"'.
+ getPref($data_dir, $username, 'full_name' . $i) .
+ '" <' .
+ getPref($data_dir, $username, 'email_address' . $i) . '>';
+ if ($enc_from_name == $orig_from && $i) {
$identity = $i;
break;
}
+ $identities[] = $enc_from_name;
}
+ $identity_match = $orig_header->findAddress($identities);
+ if ($identity_match) {
+ $identity = $identity_match;
+ }
}
switch ($action) {
$send_to_cc = replyAllString($orig_header);
case ('reply'):
$send_to = $orig_header->reply_to;
- if (is_object($send_to)) {
- $send_to = decodeHeader($send_to->getAddr_s('reply_to'));
- } else {
+ if (is_array($send_to) && count($send_to)) {
+ $send_to = decodeHeader($orig_header->getAddr_s('reply_to'));
+ } else if (is_object($send_to)) { /* unnessecarry, just for falesafe purpose */
+ $send_to = decodeHeader($orig_header->getAddr_s('reply_to'));
+ } else {
$send_to = decodeHeader($orig_header->getAddr_s('from'));
}
$subject = decodeHeader($orig_header->subject);
$username, $data_dir, $identity, $draft_id, $delete_draft,
$mailprio, $default_use_mdn, $mdn_user_support, $compose_new_win,
$saved_draft, $mail_sent, $sig_first, $edit_as_new, $action,
- $username, $compose_messages, $composesession;
+ $username, $compose_messages, $composesession, $default_charset;
$composeMessage = $compose_messages[$session];
}
if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
if ($sig_first == '1') {
- if ($charset == 'iso-2022-jp') {
+ if ($default_charset == 'iso-2022-jp') {
echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
} else {
echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature);
}
else {
echo "\n\n".htmlspecialchars($body);
- if ($charset == 'iso-2022-jp') {
+ if ($default_charset == 'iso-2022-jp') {
echo "\n\n".($prefix_sig==true? "-- \n":'').mb_convert_encoding($signature, 'EUC-JP');
}else{
echo "\n\n".($prefix_sig==true? "-- \n":'').htmlspecialchars($signature);
}
/* This code is for attachments */
+ if ((bool) ini_get('file_uploads')) {
echo ' <TR>' . "\n" .
' <TD COLSPAN=2>' . "\n" .
' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.
' </TABLE>' . "\n" .
' </TD>' . "\n" .
' </TR>' . "\n";
-
+ } // End of file_uploads if-block
/* End of attachment code */
if ($compose_new_win == '1') {
echo '</TABLE>'."\n";
}
+
echo '</TABLE>' . "\n" .
'<input type="hidden" name="username" value="'. $username . "\">\n" .
'<input type=hidden name=action value="' . $action . "\">\n" .
echo '<input type=hidden name=composesession value="' . $composesession . "\">\n";
echo '<input type=hidden name=querystring value="' . $_SERVER['QUERY_STRING'] . "\">\n";
echo '</FORM>';
+ if (!(bool) ini_get('file_uploads')) {
+ /* File uploads are off, so we didn't show that part of the form.
+ To avoid bogus bug reports, tell the user why. */
+ echo 'Because PHP file uploads are turned off, you can not attach files ';
+ echo "to this message. Please see your system administrator for details.\r\n";
+ }
+
+
do_hook('compose_bottom');
echo '</BODY></HTML>' . "\n";
}
The message also should be constructed by the message class.
*/
-function sendMessage($composeMessage, $draft=false) {
+function deliverMessage($composeMessage, $draft=false) {
global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body,
$username, $popuser, $usernamedata, $identity, $data_dir,
$request_mdn, $request_dr, $default_charset, $color, $useSendmail,
if ($full_name) {
$from = $rfc822_header->from[0];
if (!$from->host) $from->host = $domain;
- $from_addr = $full_name .' <'.$from->mailbox.'@'.$from->host.'>';
+ $from_addr = '"'.$full_name .'" <'.$from->mailbox.'@'.$from->host.'>';
$rfc822_header->from = $rfc822_header->parseAddress($from_addr,true);
}
if ($reply_to) {
if (!$useSendmail && !$draft) {
require_once(SM_PATH . 'class/deliver/Deliver_SMTP.class.php');
$deliver = new Deliver_SMTP();
- global $smtpServerAddress, $smtpPort, $use_authenticated_smtp, $pop_before_smtp;
- if ($use_authenticated_smtp) {
- global $key, $onetimepad;
- $user = $username;
- $pass = OneTimePadDecrypt($key, $onetimepad);
+ global $smtpServerAddress, $smtpPort, $pop_before_smtp, $smtp_auth_mech;
+
+ if ($smtp_auth_mech == 'none') {
+ $user = '';
+ $pass = '';
} else {
- $user = '';
- $pass = '';
+ global $key, $onetimepad;
+ $user = $username;
+ $pass = OneTimePadDecrypt($key, $onetimepad);
}
+
$authPop = (isset($pop_before_smtp) && $pop_before_smtp) ? true : false;
$stream = $deliver->initStream($composeMessage,$domain,0,
- $smtpServerAddress, $smtpPort, $authPop);
+ $smtpServerAddress, $smtpPort, $user, $pass, $authPop);
} elseif (!$draft) {
require_once(SM_PATH . 'class/deliver/Deliver_SendMail.class.php');
global $sendmail_path;
$length = $imap_deliver->mail($composeMessage);
sqimap_append ($imap_stream, $draft_folder, $length);
$imap_deliver->mail($composeMessage, $imap_stream);
- sqimap_append_done ($imap_stream);
+ sqimap_append_done ($imap_stream, $draft_folder);
sqimap_logout($imap_stream);
unset ($imap_deliver);
return $length;
require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php');
$imap_deliver = new Deliver_IMAP();
$imap_deliver->mail($composeMessage, $imap_stream);
- sqimap_append_done ($imap_stream);
+ sqimap_append_done ($imap_stream, $sent_folder);
unset ($imap_deliver);
}
global $passed_id, $mailbox, $action;