4 // send email notification if requested.
8 'notify_flags' => $importer['notify_flags'],
9 'language' => $importer['language'],
10 'to_name' => $importer['username'],
11 'to_email' => $importer['email'],
13 'source_name' => $msg['from-name'],
14 'source_link' => $importer['url'],
15 'source_photo' => $importer['thumb'],
18 //notification($notif_params);
21 function notification($params) {
24 $banner = t('Friendica Notification');
25 $product = FRIENDICA_PLATFORM;
27 $thanks = t('Thank You,');
28 $sitename = get_config('config','sitename');
29 $site_admin = sprintf( t('%s Administrator'), $sitename);
31 $sender_name = t('Administrator');
32 $sender_email = t('noreply') . '@' . $a->get_hostname();
34 $title = $params['item']['title'];
35 $body = $params['item']['body'];
37 if($params['type'] == NOTIFY_MAIL) {
39 $subject = sprintf( t('New mail received at %s'),$sitename);
41 $preamble = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename);
42 $sitelink = t('Please visit %s to view and/or reply to your private messages.');
43 $tsitelink = sprintf( $email_visit, $siteurl . '/message' );
44 $hsitelink = sprintf( $email_visit, '<a href="' . $siteurl . '/message">' . $sitename . '</a>');
49 // send email notification if notification preferences permit
51 require_once('bbcode.php');
52 if(intval($params['notify-flags']) & intval($params['type'])) {
54 push_lang($params['language']);
57 $msg['fromname'] = $sender_name;
58 $msg['fromemail'] = $sender_email;
60 $msg['textversion'] = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
61 $body))),ENT_QUOTES,'UTF-8'));
62 $msg['htmlversion'] = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
65 // load the template for private message notifications
66 $tpl = get_view_template('email_notify_html.tpl');
67 $email_html_body_tpl = replace_macros($tpl,array(
69 '$product' => $product,
70 '$preamble' => $preamble,
71 '$source_name' => $parama['source_name'],
72 '$source_link' => $params['source_link'],
73 '$source_photo' => $params['source_photo'],
74 '$username' => $params['to_name'],
75 '$hsitelink' => $hsitelink,
77 '$site_admin' => $site_admin,
78 '$title' => stripslashes($msg['title']), // subject of the message
79 '$htmlversion' => $msg['htmlversion'], // html version of the message
83 // load the template for private message notifications
84 $tpl = get_intltext_template('mail_received_text_body_eml.tpl');
85 $email_text_body_tpl = replace_macros($tpl,array(
86 '$username' => $importer['username'],
87 '$siteName' => $a->config['sitename'], // name of this site
88 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
89 '$thumb' => $importer['thumb'], // thumbnail url for sender icon
90 '$email' => $importer['email'], // email address to send to
91 '$url' => $importer['url'], // full url for the site
92 '$from' => $msg['from-name'], // name of the person sending the message
93 '$title' => stripslashes($msg['title']), // subject of the message
94 '$textversion' => $msg['textversion'], // text version of the message
95 '$mimeboundary' => $msg['mimeboundary'], // mime message divider
96 '$hostname' => $a->get_hostname() // name of this host
99 // use the EmailNotification library to send the message
100 require_once("include/EmailNotification.php");
101 EmailNotification::sendTextHtmlEmail(
102 $msg['notificationfromname'],
103 $msg['notificationfromemail'],
104 $msg['notificationfromemail'],
107 $email_html_body_tpl,
114 require_once('include/email.php');
118 * Send a multipart/alternative message with Text and HTML versions
120 * @param fromName name of the sender
121 * @param fromEmail email fo the sender
122 * @param replyTo replyTo address to direct responses
123 * @param toEmail destination email address
124 * @param messageSubject subject of the message
125 * @param htmlVersion html version of the message
126 * @param textVersion text only version of the message
128 static public function send($params) {
129 $fromName = email_header_encode($params['fromName'],'UTF-8');
130 $messageSubject = email_header_encode($params['messageSubject'],'UTF-8');
133 // generate a mime boundary
134 $mimeBoundary =rand(0,9)."-"
135 .rand(10000000000,9999999999)."-"
136 .rand(10000000000,9999999999)."=:"
139 // generate a multipart/alternative message header
141 "From: {$params['fromName']} <{$params['fromEmail']}>\n" .
142 "Reply-To: {$params['replyTo']}\n" .
143 "MIME-Version: 1.0\n" .
144 "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
146 // assemble the final multipart message body with the text and html types included
147 $textBody = chunk_split(base64_encode($params['textVersion']));
148 $htmlBody = chunk_split(base64_encode($params['htmlVersion']));
149 $multipartMessageBody =
150 "--" . $mimeBoundary . "\n" . // plain text section
151 "Content-Type: text/plain; charset=UTF-8\n" .
152 "Content-Transfer-Encoding: base64\n\n" .
154 "--" . $mimeBoundary . "\n" . // text/html section
155 "Content-Type: text/html; charset=UTF-8\n" .
156 "Content-Transfer-Encoding: base64\n\n" .
158 "--" . $mimeBoundary . "--\n"; // message ending
162 $toEmail, // send to address
163 $messageSubject, // subject
164 $multipartMessageBody, // message body
165 $messageHeader // message headers
167 logger("sendTextHtmlEmail: returns " . $res, LOGGER_DEBUG);