Commit dbe6b979d7e07b47aa4cab5c7ccf54d3ba24f319

  • avatar
  • Craig Andrews (Committer)
  • Fri Mar 05 05:10:27 CET 2010
  • avatar
  • Dave Hall <info @dave…ll.com.au> (Author)
  • Thu Mar 04 07:07:40 CET 2010
implement mail headers
lib/mail.php
(50 / 16)
  
133133 * @param User &$user user to send email to
134134 * @param string $subject subject of the email
135135 * @param string $body body of the email
136 * @param array $headers optional list of email headers
136137 * @param string $address optional specification of email address
137138 *
138139 * @return boolean success flag
139140 */
140141
141function mail_to_user(&$user, $subject, $body, $address=null)
142function mail_to_user(&$user, $subject, $body, $headers=array(), $address=null)
142143{
143144 if (!$address) {
144145 $address = $user->email;
181181 $nickname, common_config('site', 'name'),
182182 common_local_url('confirmaddress', array('code' => $code)),
183183 common_config('site', 'name'));
184 return mail_to_user($user, $subject, $body, $address);
184 $headers = array();
185
186 return mail_to_user($user, $subject, $body, $headers, $address);
185187}
186188
187189/**
234234
235235 $recipients = $listenee->email;
236236
237 $headers = _mail_prepare_headers('subscribe', $listenee->nickname, $other->nickname);
237238 $headers['From'] = mail_notify_from();
238239 $headers['To'] = $name . ' <' . $listenee->email . '>';
239240 $headers['Subject'] = sprintf(_('%1$s is now listening to '.
480480 common_local_url('all', array('nickname' => $to->nickname)),
481481 common_config('site', 'name'));
482482 common_init_locale();
483 return mail_to_user($to, $subject, $body);
483
484 $headers = _mail_prepare_headers('nudge', $to->nickname, $from->nickname);
485
486 return mail_to_user($to, $subject, $body, $headers);
484487}
485488
486489/**
533533 common_local_url('newmessage', array('to' => $from->id)),
534534 common_config('site', 'name'));
535535
536 $headers = _mail_prepare_headers('message', $to->nickname, $from->nickname);
537
536538 common_init_locale();
537 return mail_to_user($to, $subject, $body);
539 return mail_to_user($to, $subject, $body, $headers);
538540}
539541
540542/**
587587 common_config('site', 'name'),
588588 $user->nickname);
589589
590 $headers = _mail_prepare_headers('fave', $other->nickname, $user->nickname);
591
590592 common_init_locale();
591 mail_to_user($other, $subject, $body);
593 mail_to_user($other, $subject, $body, $headers);
592594}
593595
594596/**
622622
623623 common_init_locale($user->language);
624624
625 if ($notice->conversation != $notice->id) {
626 $conversationEmailText = "The full conversation can be read here:\n\n".
627 "\t%5\$s\n\n ";
628 $conversationUrl = common_local_url('conversation',
625 if ($notice->conversation != $notice->id) {
626 $conversationEmailText = "The full conversation can be read here:\n\n".
627 "\t%5\$s\n\n ";
628 $conversationUrl = common_local_url('conversation',
629629 array('id' => $notice->conversation)).'#notice-'.$notice->id;
630 } else {
631 $conversationEmailText = "%5\$s";
632 $conversationUrl = null;
633 }
630 } else {
631 $conversationEmailText = "%5\$s";
632 $conversationUrl = null;
633 }
634634
635635 $subject = sprintf(_('%s (@%s) sent a notice to your attention'), $bestname, $sender->nickname);
636636
637 $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
637 $body = sprintf(_("%1\$s (@%9\$s) just sent a notice to your attention (an '@-reply') on %2\$s.\n\n".
638638 "The notice is here:\n\n".
639639 "\t%3\$s\n\n" .
640640 "It reads:\n\n".
652652 common_local_url('shownotice',
653653 array('notice' => $notice->id)),//%3
654654 $notice->content,//%4
655 $conversationUrl,//%5
655 $conversationUrl,//%5
656656 common_local_url('newnotice',
657657 array('replyto' => $sender->nickname, 'inreplyto' => $notice->id)),//%6
658658 common_local_url('replies',
660660 common_local_url('emailsettings'), //%8
661661 $sender->nickname); //%9
662662
663 $headers = _mail_prepare_headers('mention', $user->nickname, $sender->nickname);
664
663665 common_init_locale();
664 mail_to_user($user, $subject, $body);
666 mail_to_user($user, $subject, $body, $headers);
667}
668
669/**
670 * Prepare the common mail headers used in notification emails
671 *
672 * @param string $msg_type type of message being sent to the user
673 * @param string $to nickname of the receipient
674 * @param string $from nickname of the user triggering the notification
675 *
676 * @return array list of mail headers to include in the message
677 */
678function _mail_prepare_headers($msg_type, $to, $from)
679{
680 $headers = array(
681 'X-StatusNet-MessageType' => $msg_type,
682 'X-StatusNet-TargetUser' => $to,
683 'X-StatusNet-SourceUser' => $from,
684 'X-StatusNet-Domain' => common_config('site', 'server')
685 );
686
687 return $headers;
665688}