1*479c05b1SMichael Große<?php 2*479c05b1SMichael Große 3*479c05b1SMichael Großenamespace dokuwiki\Subscriptions; 4*479c05b1SMichael Große 5*479c05b1SMichael Große 6*479c05b1SMichael Großeuse Mailer; 7*479c05b1SMichael Große 8*479c05b1SMichael Großeabstract class SubscriptionSender 9*479c05b1SMichael Große{ 10*479c05b1SMichael Große 11*479c05b1SMichael Große 12*479c05b1SMichael Große /** 13*479c05b1SMichael Große * Helper function for sending a mail 14*479c05b1SMichael Große * 15*479c05b1SMichael Große * @author Adrian Lang <lang@cosmocode.de> 16*479c05b1SMichael Große * 17*479c05b1SMichael Große * @param string $subscriber_mail The target mail address 18*479c05b1SMichael Große * @param string $subject The lang id of the mail subject (without the 19*479c05b1SMichael Große * prefix “mail_”) 20*479c05b1SMichael Große * @param string $context The context of this mail, eg. page or namespace id 21*479c05b1SMichael Große * @param string $template The name of the mail template 22*479c05b1SMichael Große * @param array $trep Predefined parameters used to parse the 23*479c05b1SMichael Große * template (in text format) 24*479c05b1SMichael Große * @param array $hrep Predefined parameters used to parse the 25*479c05b1SMichael Große * template (in HTML format), null to default to $trep 26*479c05b1SMichael Große * @param array $headers Additional mail headers in the form 'name' => 'value' 27*479c05b1SMichael Große * @return bool 28*479c05b1SMichael Große */ 29*479c05b1SMichael Große protected function send($subscriber_mail, $subject, $context, $template, $trep, $hrep = null, $headers = array()) { 30*479c05b1SMichael Große global $lang; 31*479c05b1SMichael Große global $conf; 32*479c05b1SMichael Große 33*479c05b1SMichael Große $text = rawLocale($template); 34*479c05b1SMichael Große $subject = $lang['mail_'.$subject].' '.$context; 35*479c05b1SMichael Große $mail = new Mailer(); 36*479c05b1SMichael Große $mail->bcc($subscriber_mail); 37*479c05b1SMichael Große $mail->subject($subject); 38*479c05b1SMichael Große $mail->setBody($text, $trep, $hrep); 39*479c05b1SMichael Große if(in_array($template, array('subscr_list', 'subscr_digest'))){ 40*479c05b1SMichael Große $mail->from($conf['mailfromnobody']); 41*479c05b1SMichael Große } 42*479c05b1SMichael Große if(isset($trep['SUBSCRIBE'])) { 43*479c05b1SMichael Große $mail->setHeader('List-Unsubscribe', '<'.$trep['SUBSCRIBE'].'>', false); 44*479c05b1SMichael Große } 45*479c05b1SMichael Große 46*479c05b1SMichael Große foreach ($headers as $header => $value) { 47*479c05b1SMichael Große $mail->setHeader($header, $value); 48*479c05b1SMichael Große } 49*479c05b1SMichael Große 50*479c05b1SMichael Große return $mail->send(); 51*479c05b1SMichael Große } 52*479c05b1SMichael Große 53*479c05b1SMichael Große} 54