Blame view
sources/3rdparty/sabre/dav/lib/Sabre/CalDAV/Schedule/IMip.php
3.23 KB
|
03e52840d
|
1 |
<?php |
|
6d9380f96
|
2 |
namespace Sabre\CalDAV\Schedule; |
|
03e52840d
|
3 |
use Sabre\VObject; |
|
6d9380f96
|
4 |
use Sabre\DAV; |
|
03e52840d
|
5 6 7 8 9 10 11 12 13 14 15 |
/** * iMIP handler. * * This class is responsible for sending out iMIP messages. iMIP is the * email-based transport for iTIP. iTIP deals with scheduling operations for * iCalendar objects. * * If you want to customize the email that gets sent out, you can do so by * extending this class and overriding the sendMessage method. * |
|
6d9380f96
|
16 17 18 |
* @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License |
|
03e52840d
|
19 |
*/ |
|
6d9380f96
|
20 |
class IMip {
|
|
03e52840d
|
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
/**
* Email address used in From: header.
*
* @var string
*/
protected $senderEmail;
/**
* Creates the email handler.
*
* @param string $senderEmail. The 'senderEmail' is the email that shows up
* in the 'From:' address. This should
* generally be some kind of no-reply email
* address you own.
*/
public function __construct($senderEmail) {
$this->senderEmail = $senderEmail;
}
/**
* Sends one or more iTip messages through email.
*
* @param string $originator Originator Email
* @param array $recipients Array of email addresses
|
|
6d9380f96
|
48 |
* @param VObject\Component $vObject |
|
03e52840d
|
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
* @param string $principal Principal Url of the originator
* @return void
*/
public function sendMessage($originator, array $recipients, VObject\Component $vObject, $principal) {
foreach($recipients as $recipient) {
$to = $recipient;
$replyTo = $originator;
$subject = 'SabreDAV iTIP message';
switch(strtoupper($vObject->METHOD)) {
case 'REPLY' :
$subject = 'Response for: ' . $vObject->VEVENT->SUMMARY;
break;
case 'REQUEST' :
$subject = 'Invitation for: ' .$vObject->VEVENT->SUMMARY;
break;
case 'CANCEL' :
$subject = 'Cancelled event: ' . $vObject->VEVENT->SUMMARY;
break;
}
$headers = array();
$headers[] = 'Reply-To: ' . $replyTo;
$headers[] = 'From: ' . $this->senderEmail;
$headers[] = 'Content-Type: text/calendar; method=' . (string)$vObject->method . '; charset=utf-8';
|
|
6d9380f96
|
76 77 |
if (DAV\Server::$exposeVersion) {
$headers[] = 'X-Sabre-Version: ' . DAV\Version::VERSION . '-' . DAV\Version::STABILITY;
|
|
03e52840d
|
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
}
$vcalBody = $vObject->serialize();
$this->mail($to, $subject, $vcalBody, $headers);
}
}
// @codeCoverageIgnoreStart
// This is deemed untestable in a reasonable manner
/**
* This function is reponsible for sending the actual email.
*
* @param string $to Recipient email address
* @param string $subject Subject of the email
* @param string $body iCalendar body
* @param array $headers List of headers
* @return void
*/
protected function mail($to, $subject, $body, array $headers) {
mail($to, $subject, $body, implode("\r
", $headers));
}
// @codeCoverageIgnoreEnd
}
|