function send_mail_multipart($from, $from_address, $to, $to_address, $subject, $body_plain, $body_html, $charset) { global $emailAnnounce; $body_html = add_host_to_urls($body_html); if (count($to_address) > 1) { if (isset($emailAnnounce)) { if (empty($to)) { $to_header = $emailAnnounce; } else { $to_header = $to . " <{$emailAnnounce}>"; } } else { if (empty($to)) { $to_header = '(undisclosed recipients)'; } else { $to_header = "({$to})"; } } $bcc = 'Bcc: ' . join(', ', $to_address) . PHP_EOL; } else { if (empty($to)) { if (is_array($to_address)) { $to_header = $to_address[0]; } else { $to_header = $to_address; } } else { if (is_array($to_address)) { $to_header = qencode($to, $charset) . " <{$to_address[0]}>"; } else { $to_header = qencode($to, $charset) . " <{$to_address}>"; } } $bcc = ''; } $separator = uniqid('==eClass-Multipart_Boundary_0_', true) . '_' . md5(time()); $headers = from($from, $from_address) . $bcc . "MIME-Version: 1.0" . PHP_EOL . "Content-Type: multipart/alternative;" . PHP_EOL . " boundary=\"{$separator}\"" . reply_to($from, $from_address); $body = "This is a multi-part message in MIME format." . PHP_EOL . PHP_EOL . "--{$separator}" . PHP_EOL . "Content-Type: text/plain; charset={$charset}" . PHP_EOL . "Content-Transfer-Encoding: 8bit\n\n{$body_plain}" . PHP_EOL . PHP_EOL . "--{$separator}" . PHP_EOL . "Content-Type: text/html; charset={$charset}" . PHP_EOL . "Content-Transfer-Encoding: 8bit" . PHP_EOL . PHP_EOL . "<html><head><meta http-equiv='Content-Type' " . "content='text/html; charset=\"{$charset}\"'>" . "<title>message</title></head><body>\n" . "{$body_html}\n</body></html>" . PHP_EOL . "--{$separator}--" . PHP_EOL; return @mail($to_header, qencode($subject, $charset), $body, $headers); }
function send_mail_multipart($from, $from_address, $to, $to_address, $subject, $body_plain, $body_html, $charset) { if (is_array($to_address) and !count($to_address) or empty($to_address)) { return true; } $emailAnnounce = get_config('email_announce'); $body_html = add_host_to_urls($body_html); if (count($to_address) > 1) { if (isset($emailAnnounce) and !empty($emailAnnounce)) { if (empty($to)) { $to_header = $emailAnnounce; } else { $to_header = $to . " <{$emailAnnounce}>"; } } else { if (empty($to)) { $to_header = '(undisclosed recipients)'; } else { $to_header = "({$to})"; } } $bcc = 'Bcc: ' . join(', ', $to_address) . PHP_EOL; } else { if (empty($to)) { if (is_array($to_address)) { $to_header = $to_address[0]; } else { $to_header = $to_address; } } else { if (is_array($to_address)) { $to_header = qencode($to, $charset) . " <{$to_address[0]}>"; } else { $to_header = qencode($to, $charset) . " <{$to_address}>"; } } $bcc = ''; } $separator = uniqid('==eClass-Multipart_Boundary_0_', true) . '_' . md5(time()); $headers = from($from, $from_address) . $bcc . "MIME-Version: 1.0" . PHP_EOL . "Content-Type: multipart/alternative;" . PHP_EOL . " boundary=\"{$separator}\"" . reply_to($from, $from_address); $body = "This is a multi-part message in MIME format." . PHP_EOL . PHP_EOL . "--{$separator}" . PHP_EOL . "Content-Type: text/plain; charset={$charset}" . PHP_EOL . "Content-Transfer-Encoding: 8bit\n\n{$body_plain}" . PHP_EOL . PHP_EOL . "--{$separator}" . PHP_EOL . "Content-Type: text/html; charset={$charset}" . PHP_EOL . "Content-Transfer-Encoding: 8bit" . PHP_EOL . PHP_EOL . "<html><head><meta http-equiv='Content-Type' " . "content='text/html; charset=\"{$charset}\"'>" . "<title>message</title>" . "<style type='text/css'>\n /* General Styles */\n body{ padding: 0px; margin: 0px; color: #555; background-color: #f7f7f7; font-family: 'Helvetica', sans-serif; font-size: 1em; }\n #container{ margin: 20px; padding: 10px; background-color: #fefefe; }\n #mail-header, #mail-body, #mail-footer{ padding: 0 15px 15px; }\n hr{ margin: 0px; }\n\n /* Header Styles */\n #mail-header{ padding-top: 10px; border-bottom: 1px solid #ddd; color: #666; }\n #header-title{ background-color: #f5f5f5; margin-left: -15px; margin-right: -15px; padding: 12px 15px; font-weight: bold; }\n #forum-category{ list-style: none; padding-left: 0px; }\n #forum-category li{ padding-bottom: 1px; }\n #forum-category li span:first-child{ width: 150px; }\n #forum-category li span:last-child{ padding-left: 10px; }\n #forum-category{ margin-bottom: 0px; }\n\n /* Body Styles */\n #mail-body-inner{ padding-left: 30px; padding-right: 30px; }\n\n /* Footer Styles */\n #mail-footer{ padding-bottom: 25px; border-top: 1px solid #ddd; color: #888; position: relative; }\n #mail-footer-left{ float: left; width: 8%; width: 80px; }\n #mail-footer-right{ float: left; width: 90%; }\n b.notice{ color: #555; }\n </style>\n" . "</head><body><div id='container'>\n" . "{$body_html}\n</div></body></html>" . PHP_EOL . "--{$separator}--" . PHP_EOL; return @mail($to_header, qencode($subject, $charset), $body, $headers); }