]> git.mxchange.org Git - friendica.git/blob - include/EmailNotification.php
improved UI for checked items to be deleted
[friendica.git] / include / EmailNotification.php
1 <?php
2 class EmailNotification {
3         /**
4          * Send a multipart/alternative message with Text and HTML versions
5          *
6          * @param fromName                      name of the sender
7          * @param fromEmail                     email fo the sender
8          * @param replyTo                       replyTo address to direct responses
9          * @param toEmail                       destination email address
10          * @param messageSubject        subject of the message
11          * @param htmlVersion           html version of the message
12          * @param textVersion           text only version of the message
13          */
14         static public function sendTextHtmlEmail($fromName,$fromEmail,$replyTo,$toEmail,$messageSubject,$htmlVersion,$textVersion) {
15                 
16                 // generate a mime boundary
17                 $mimeBoundary   =rand(0,9)."-"
18                                 .rand(10000000000,9999999999)."-"
19                                 .rand(10000000000,9999999999)."=:"
20                                 .rand(10000,99999);
21
22                 // generate a multipart/alternative message header
23                 $messageHeader =
24                         "From: {$fromName} <{$fromEmail}>\n" . 
25                         "Reply-To: {$replyTo}\n" .
26                         "MIME-Version: 1.0\n" .
27                         "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
28
29                 // assemble the final multipart message body with the text and html types included
30                 $textBody       =       chunk_split(base64_encode($textVersion));
31                 $htmlBody       =       chunk_split(base64_encode($htmlVersion));
32                 $multipartMessageBody =
33                         "--" . $mimeBoundary . "\n" .                                   // plain text section
34                         "Content-Type: text/plain; charset=UTF-8\n" .
35                         "Content-Transfer-Encoding: base64\n\n" .
36                         $textBody . "\n" .
37                         "--" . $mimeBoundary . "\n" .                                   // text/html section
38                         "Content-Type: text/html; charset=UTF-8\n" .
39                         "Content-Transfer-Encoding: base64\n\n" .
40                         $htmlBody . "\n" .
41                         "--" . $mimeBoundary . "--\n";                                  // message ending
42
43                 // send the message
44                 $res = mail(
45                         $toEmail,                                                                               // send to address
46                         $messageSubject,                                                                // subject
47                         $multipartMessageBody,                                                  // message body
48                         $messageHeader                                                                  // message headers
49                 );
50                 logger("sendTextHtmlEmail: END");
51         }
52 }
53 ?>