summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2010-11-19 08:45:19 +0000
committeralecpl <alec@alec.pl>2010-11-19 08:45:19 +0000
commitd2b8840a0e1c6877716517727ec9e1bbded20733 (patch)
treed969463daaf88a1f2264c31b0eb75dd1e5f27197 /program/steps/mail
parente9a974990e6bceb2db0f814bc09671e36d441da6 (diff)
- Fix handling of custom "_from" in sendmail (#1487132)
- Small fix in displaying Sender input field
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/compose.inc9
-rw-r--r--program/steps/mail/sendmail.inc61
2 files changed, 40 insertions, 30 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 3f2b8c5d2..ec9b4ef0d 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -472,7 +472,7 @@ function rcmail_compose_header_from($attrib)
$from_id = get_input_value('_from', RCUBE_INPUT_POST);
else if (!empty($_SESSION['compose']['param']['from']))
$from_id = $_SESSION['compose']['param']['from'];
- else if (count($user_identities) > 1) {
+ else {
$return_path = $MESSAGE->headers->others['return-path'];
// Set identity
@@ -501,10 +501,11 @@ function rcmail_compose_header_from($attrib)
// add signatures to client
$OUTPUT->set_env('signatures', $a_signatures);
}
- else
- {
+ // no identities, display text input field
+ else {
+ $field_attrib['class'] = 'from_address';
$input_from = new html_inputfield($field_attrib);
- $out = $input_from->show($_POST['_from']);
+ $out = $input_from->show($from_id);
}
return $out;
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 81e5a214e..54ded7af0 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -212,7 +212,7 @@ $mailcc = rcmail_email_input_format(get_input_value('_cc', RCUBE_INPUT_POST, TRU
$mailbcc = rcmail_email_input_format(get_input_value('_bcc', RCUBE_INPUT_POST, TRUE, $message_charset), true);
if ($EMAIL_FORMAT_ERROR) {
- $OUTPUT->show_message('emailformaterror', 'error', array('email' => $EMAIL_FORMAT_ERROR));
+ $OUTPUT->show_message('emailformaterror', 'error', array('email' => $EMAIL_FORMAT_ERROR));
$OUTPUT->send('iframe');
}
@@ -223,18 +223,30 @@ if (empty($mailto) && !empty($mailcc)) {
else if (empty($mailto))
$mailto = 'undisclosed-recipients:;';
-// get sender name and address
+// Get sender name and address...
$from = get_input_value('_from', RCUBE_INPUT_POST, true, $message_charset);
-$identity_arr = rcmail_get_identity($from);
-
-if (!$identity_arr && ($from = rcmail_email_input_format($from))) {
- if (preg_match('/(\S+@\S+)/', $from, $m))
- $identity_arr['mailto'] = $m[1];
-} else
- $from = $identity_arr['mailto'];
+// ... from identity...
+if (is_numeric($from)) {
+ if (is_array($identity_arr = rcmail_get_identity($from))) {
+ if ($identity_arr['mailto'])
+ $from = $identity_arr['mailto'];
+ if ($identity_arr['string'])
+ $from_string = $identity_arr['string'];
+ }
+ else {
+ $from = null;
+ }
+}
+// ... if there is no identity record, this might be a custom from
+else if ($from_string = rcmail_email_input_format($from)) {
+ if (preg_match('/(\S+@\S+)/', $from_string, $m))
+ $from = trim($m[1], '<>');
+ else
+ $from = null;
+}
-if (empty($identity_arr['string']))
- $identity_arr['string'] = $from;
+if (!$from_string && $from)
+ $from_string = $from;
// compose headers array
$headers = array();
@@ -281,7 +293,7 @@ if ($CONFIG['http_received_header'])
}
$headers['Date'] = rcmail_user_date();
-$headers['From'] = rcube_charset_convert($identity_arr['string'], RCMAIL_CHARSET, $message_charset);
+$headers['From'] = rcube_charset_convert($from_string, RCMAIL_CHARSET, $message_charset);
$headers['To'] = $mailto;
// additional recipients
@@ -331,19 +343,17 @@ else if (!empty($_SESSION['compose']['forward_uid']) && $savedraft)
if (!empty($_SESSION['compose']['references']))
$headers['References'] = $_SESSION['compose']['references'];
-if (!empty($_POST['_priority']))
- {
+if (!empty($_POST['_priority'])) {
$priority = intval($_POST['_priority']);
$a_priorities = array(1=>'highest', 2=>'high', 4=>'low', 5=>'lowest');
if ($str_priority = $a_priorities[$priority])
$headers['X-Priority'] = sprintf("%d (%s)", $priority, ucfirst($str_priority));
- }
+}
-if (!empty($_POST['_receipt']))
- {
- $headers['Return-Receipt-To'] = $identity_arr['string'];
- $headers['Disposition-Notification-To'] = $identity_arr['string'];
- }
+if (!empty($_POST['_receipt'])) {
+ $headers['Return-Receipt-To'] = $from_string;
+ $headers['Disposition-Notification-To'] = $from_string;
+}
// additional headers
$headers['Message-ID'] = $message_id;
@@ -526,8 +536,7 @@ $MAIL_MIME->setParam('html_charset', $message_charset);
$MAIL_MIME->setParam('text_charset', $message_charset . ($flowed ? ";\r\n format=flowed" : ''));
// encoding subject header with mb_encode provides better results with asian characters
-if (function_exists('mb_encode_mimeheader'))
-{
+if (function_exists('mb_encode_mimeheader')) {
mb_internal_encoding($message_charset);
$headers['Subject'] = mb_encode_mimeheader($headers['Subject'],
$message_charset, 'Q', "\r\n", 8);
@@ -537,13 +546,13 @@ if (function_exists('mb_encode_mimeheader'))
// pass headers to message object
$MAIL_MIME->headers($headers);
-// Begin SMTP Delivery Block
+// Begin SMTP Delivery Block
if (!$savedraft)
{
- // check for 'From' address (identity may be incomplete)
- if ($identity_arr && !$identity_arr['mailto']) {
+ // check 'From' address (identity may be incomplete)
+ if (empty($from)) {
$OUTPUT->show_message('nofromaddress', 'error');
- $OUTPUT->send('iframe');
+ $OUTPUT->send('iframe');
}
// Handle Delivery Status Notification request