]> git.mxchange.org Git - friendica.git/blobdiff - include/email.php
Sending mail as multipart/alternative (html and plain text) (very basic by now)
[friendica.git] / include / email.php
index 452682260a16f16c1af1274f6f14c7eba4837a51..fee3e2f6860a4b177f676d4d92322f705f49631b 100755 (executable)
@@ -1,4 +1,5 @@
 <?php
+require_once('include/html2plain.php');
 
 function email_connect($mailbox,$username,$password) {
        if(! function_exists('imap_open'))
@@ -224,6 +225,44 @@ function email_header_encode($in_str, $charset) {
         $out_str = $start . $out_str . $end;
     }
     return $out_str;
-} 
+}
+
+function email_send($addr, $subject, $headers, $item) {
+       //$headers .= 'MIME-Version: 1.0' . "\n";
+       //$headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
+       //$headers .= 'Content-Type: text/plain; charset=UTF-8' . "\n";
+       //$headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";
+       $html    = prepare_body($item);
+
+       $headers .= "Mime-Version: 1.0\n";
+       $headers .= 'Content-Type: multipart/alternative; boundary="=_1f5dbdf8dbd0a060ea5bc3050bb14c6a"'."\n\n";
+
+       $body = "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a\n";
+       $body .= "Content-Transfer-Encoding: quoted-printable\n";
+       $body .= "Content-Type: text/plain; charset=utf-8; format=flowed\n\n";
+
+       $body .= html2plain($html)."\n";
+
+       $body .= "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a\n";
+       $body .= "Content-Transfer-Encoding: quoted-printable\n";
+       $body .= "Content-Type: text/html; charset=utf-8\n\n";
+
+       $body .= $html."\n\n";
 
+       $body .= "--=_1f5dbdf8dbd0a060ea5bc3050bb14c6a--\n";
+
+       //$message = '<html><body>' . $html . '</body></html>';
+       //$message = html2plain($html);
+       logger('notifier: email delivery to ' . $addr);
+       mail($addr, $subject, $body, $headers);
+}
+
+function email_cleanupmessageid($messageid) {
+       global $a;
+
+       if (!strpos($messageid, '@'))
+               $messageid = str_replace(":", ".", $messageid).'@'.$a->get_hostname();
+
+       return($messageid);
+}