| | |
| | | global $DB; |
| | | |
| | | // get identity record |
| | | $sql_result = $DB->query(sprintf("SELECT *, email AS mailto |
| | | FROM %s |
| | | WHERE identity_id=%d |
| | | AND user_id=%d |
| | | AND del!='1'", |
| | | get_table_name('identities'), |
| | | $id, |
| | | $_SESSION['user_id'])); |
| | | $sql_result = $DB->query("SELECT *, email AS mailto |
| | | FROM ".get_table_name('identities')." |
| | | WHERE identity_id=? |
| | | AND user_id=? |
| | | AND del<>'1'", |
| | | $id,$_SESSION['user_id']); |
| | | |
| | | if ($DB->num_rows($sql_result)) |
| | | { |
| | |
| | | /****** check submission and compose message ********/ |
| | | |
| | | |
| | | $mailto_regexp = '/,\s*$/'; |
| | | $mailto_regexp = array('/,\s*[\r\n]+/', '/[\r\n]+/', '/,\s*$/m'); |
| | | $mailto_replace = array(' ', ', ', ''); |
| | | |
| | | // trip ending ', ' from |
| | | $mailto = preg_replace($mailto_regexp, '', $_POST['_to']); |
| | | // repalce new lines and strip ending ', ' |
| | | $mailto = preg_replace($mailto_regexp, $mailto_replace, stripslashes($_POST['_to'])); |
| | | |
| | | // decode address strings |
| | | $to_address_arr = $IMAP->decode_address_list($mailto); |
| | |
| | | |
| | | // additional recipients |
| | | if ($_POST['_cc']) |
| | | $headers['Cc'] = preg_replace($mailto_regexp, '', $_POST['_cc']); |
| | | $headers['Cc'] = preg_replace($mailto_regexp, $mailto_replace, stripslashes($_POST['_cc'])); |
| | | |
| | | if ($_POST['_bcc']) |
| | | $headers['Bcc'] = preg_replace($mailto_regexp, '', $_POST['_bcc']); |
| | | $headers['Bcc'] = preg_replace($mailto_regexp, $mailto_replace, stripslashes($_POST['_bcc'])); |
| | | |
| | | if (strlen($identity_arr['bcc'])) |
| | | $headers['Bcc'] = ($headers['Bcc'] ? $headers['Bcc'].', ' : '') . $identity_arr['bcc']; |
| | |
| | | unset($headers_php['To'], $headers_php['Subject']); |
| | | |
| | | $header_str = $MAIL_MIME->txtHeaders($headers_php); |
| | | $sent = mail($mailto, $msg_subject, $msg_body, $header_str, "-f$from"); |
| | | |
| | | if(ini_get('safe_mode')) |
| | | $sent = mail($mailto, $msg_subject, $msg_body, $header_str); |
| | | else |
| | | $sent = mail($mailto, $msg_subject, $msg_body, $header_str, "-f$from"); |
| | | } |
| | | |
| | | |