diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2007-12-10 15:27:19 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2007-12-10 15:27:19 +0000 |
| commit | 7a790a51bb6acd65b193660367c8af3629256907 (patch) | |
| tree | 46a1289f5e2cd9b32906f1ab037c676a829f6e9e /roundcubemail/program/steps/mail/func.inc | |
| parent | 291aa89005cb17ccbc05a95e6f0e7651230836ed (diff) | |
New class rcube_user + send message disposition notification
git-svn-id: https://svn.roundcube.net/trunk@938 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/steps/mail/func.inc')
| -rw-r--r-- | roundcubemail/program/steps/mail/func.inc | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/roundcubemail/program/steps/mail/func.inc b/roundcubemail/program/steps/mail/func.inc index dd3801672..de8987248 100644 --- a/roundcubemail/program/steps/mail/func.inc +++ b/roundcubemail/program/steps/mail/func.inc @@ -21,6 +21,7 @@ require_once('lib/html2text.inc'); require_once('lib/enriched.inc'); +require_once('include/rcube_smtp.inc'); $EMAIL_ADDRESS_PATTERN = '/([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9]\\.[a-z]{2,5})/i'; @@ -725,7 +726,7 @@ function rcmail_parse_message(&$structure, $arg=array(), $recursive=FALSE) // part text/[plain|html] OR message/delivery-status else if (($primary_type=='text' && ($secondary_type=='plain' || $secondary_type=='html') && $mail_part->disposition!='attachment') || - ($primary_type=='message' && $secondary_type=='delivery-status')) + ($primary_type=='message' && ($secondary_type=='delivery-status' || $secondary_type=='disposition-notification'))) { $mail_part->type = 'content'; $a_return_parts[] = $mail_part; @@ -758,7 +759,7 @@ function rcmail_parse_message(&$structure, $arg=array(), $recursive=FALSE) else { if (!$mail_part->filename) - $mail_part->filename = 'file_'.$mail_part->mime_id; + $mail_part->filename = 'Part '.$mail_part->mime_id; $a_attachments[] = $mail_part; } } @@ -1250,6 +1251,67 @@ function rcmail_compose_cleanup() unset($_SESSION['compose']); } + + +/** + * Send the given message compose object using the configured method + */ +function rcmail_deliver_message(&$message, $from, $mailto) +{ + global $CONFIG; + + $headers = $message->headers(); + $msg_body = $message->get(); + + // send thru SMTP server using custom SMTP library + if ($CONFIG['smtp_server']) + { + // generate list of recipients + $a_recipients = array($mailto); + + if (strlen($headers['Cc'])) + $a_recipients[] = $headers['Cc']; + if (strlen($headers['Bcc'])) + $a_recipients[] = $headers['Bcc']; + + // clean Bcc from header for recipients + $send_headers = $headers; + unset($send_headers['Bcc']); + + // send message + $smtp_response = array(); + $sent = smtp_mail($from, $a_recipients, ($foo = $message->txtHeaders($send_headers)), $msg_body, $smtp_response); + + // log error + if (!$sent) + raise_error(array('code' => 800, 'type' => 'smtp', 'line' => __LINE__, 'file' => __FILE__, + 'message' => "SMTP error: ".join("\n", $smtp_response)), TRUE, FALSE); + } + + // send mail using PHP's mail() function + else + { + // unset some headers because they will be added by the mail() function + $headers_enc = $message->headers($headers); + $headers_php = $message->_headers; + unset($headers_php['To'], $headers_php['Subject']); + + // reset stored headers and overwrite + $message->_headers = array(); + $header_str = $message->txtHeaders($headers_php); + + if (ini_get('safe_mode')) + $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str); + else + $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from"); + } + + + $message->_headers = array(); + $message->headers($headers); + + return $sent; +} // register UI objects |
