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 $new_email = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename);
42 $email_visit = t('Please visit %s to view and/or reply to your private messages.');
43 $email_tlink = sprintf( $email_visit, $siteurl . '/message' );
44 $email_hlink = 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']);
56 $msg['notificationfromname'] = $sender_name;
57 $msg['notificationfromemail'] = $sender_email;
60 = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
61 $body))),ENT_QUOTES,'UTF-8'));
63 = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"),
66 // load the template for private message notifications
67 $tpl = get_intltext_template('mail_received_html_body_eml.tpl');
68 $email_html_body_tpl = replace_macros($tpl,array(
69 '$username' => $importer['username'],
70 '$siteName' => $a->config['sitename'], // name of this site
71 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
72 '$thumb' => $importer['thumb'], // thumbnail url for sender icon
73 '$email' => $importer['email'], // email address to send to
74 '$url' => $importer['url'], // full url for the site
75 '$from' => $msg['from-name'], // name of the person sending the message
76 '$title' => stripslashes($msg['title']), // subject of the message
77 '$htmlversion' => $msg['htmlversion'], // html version of the message
78 '$mimeboundary' => $msg['mimeboundary'], // mime message divider
79 '$hostname' => $a->get_hostname() // name of this host
82 // load the template for private message notifications
83 $tpl = get_intltext_template('mail_received_text_body_eml.tpl');
84 $email_text_body_tpl = replace_macros($tpl,array(
85 '$username' => $importer['username'],
86 '$siteName' => $a->config['sitename'], // name of this site
87 '$siteurl' => $a->get_baseurl(), // descriptive url of this site
88 '$thumb' => $importer['thumb'], // thumbnail url for sender icon
89 '$email' => $importer['email'], // email address to send to
90 '$url' => $importer['url'], // full url for the site
91 '$from' => $msg['from-name'], // name of the person sending the message
92 '$title' => stripslashes($msg['title']), // subject of the message
93 '$textversion' => $msg['textversion'], // text version of the message
94 '$mimeboundary' => $msg['mimeboundary'], // mime message divider
95 '$hostname' => $a->get_hostname() // name of this host
98 // use the EmailNotification library to send the message
99 require_once("include/EmailNotification.php");
100 EmailNotification::sendTextHtmlEmail(
101 $msg['notificationfromname'],
102 $msg['notificationfromemail'],
103 $msg['notificationfromemail'],
106 $email_html_body_tpl,
113 require_once('include/email.php');
117 * Send a multipart/alternative message with Text and HTML versions
119 * @param fromName name of the sender
120 * @param fromEmail email fo the sender
121 * @param replyTo replyTo address to direct responses
122 * @param toEmail destination email address
123 * @param messageSubject subject of the message
124 * @param htmlVersion html version of the message
125 * @param textVersion text only version of the message
127 static public function send($params) {
128 $fromName = email_header_encode($params['fromName'],'UTF-8');
129 $messageSubject = email_header_encode($params['messageSubject'],'UTF-8');
132 // generate a mime boundary
133 $mimeBoundary =rand(0,9)."-"
134 .rand(10000000000,9999999999)."-"
135 .rand(10000000000,9999999999)."=:"
138 // generate a multipart/alternative message header
140 "From: {$params['fromName']} <{$params['fromEmail']}>\n" .
141 "Reply-To: {$params['replyTo']}\n" .
142 "MIME-Version: 1.0\n" .
143 "Content-Type: multipart/alternative; boundary=\"{$mimeBoundary}\"";
145 // assemble the final multipart message body with the text and html types included
146 $textBody = chunk_split(base64_encode($params['textVersion']));
147 $htmlBody = chunk_split(base64_encode($params['htmlVersion']));
148 $multipartMessageBody =
149 "--" . $mimeBoundary . "\n" . // plain text section
150 "Content-Type: text/plain; charset=UTF-8\n" .
151 "Content-Transfer-Encoding: base64\n\n" .
153 "--" . $mimeBoundary . "\n" . // text/html section
154 "Content-Type: text/html; charset=UTF-8\n" .
155 "Content-Transfer-Encoding: base64\n\n" .
157 "--" . $mimeBoundary . "--\n"; // message ending
161 $toEmail, // send to address
162 $messageSubject, // subject
163 $multipartMessageBody, // message body
164 $messageHeader // message headers
166 logger("sendTextHtmlEmail: returns " . $res, LOGGER_DEBUG);