@@ -29,25 +29,25 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | interface IAttachment { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $filename |
|
| 34 | - * @return $this |
|
| 35 | - * @since 13.0.0 |
|
| 36 | - */ |
|
| 37 | - public function setFilename($filename); |
|
| 32 | + /** |
|
| 33 | + * @param string $filename |
|
| 34 | + * @return $this |
|
| 35 | + * @since 13.0.0 |
|
| 36 | + */ |
|
| 37 | + public function setFilename($filename); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $contentType |
|
| 41 | - * @return $this |
|
| 42 | - * @since 13.0.0 |
|
| 43 | - */ |
|
| 44 | - public function setContentType($contentType); |
|
| 39 | + /** |
|
| 40 | + * @param string $contentType |
|
| 41 | + * @return $this |
|
| 42 | + * @since 13.0.0 |
|
| 43 | + */ |
|
| 44 | + public function setContentType($contentType); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param string $body |
|
| 48 | - * @return $this |
|
| 49 | - * @since 13.0.0 |
|
| 50 | - */ |
|
| 51 | - public function setBody($body); |
|
| 46 | + /** |
|
| 47 | + * @param string $body |
|
| 48 | + * @return $this |
|
| 49 | + * @since 13.0.0 |
|
| 50 | + */ |
|
| 51 | + public function setBody($body); |
|
| 52 | 52 | |
| 53 | 53 | } |
@@ -29,70 +29,70 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | interface IMessage { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @return IAttachment |
|
| 34 | - * @since 13.0.0 |
|
| 35 | - */ |
|
| 36 | - public function createAttachment(); |
|
| 32 | + /** |
|
| 33 | + * @return IAttachment |
|
| 34 | + * @since 13.0.0 |
|
| 35 | + */ |
|
| 36 | + public function createAttachment(); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param IAttachment $attachment |
|
| 40 | - * @return $this |
|
| 41 | - * @since 13.0.0 |
|
| 42 | - */ |
|
| 43 | - public function attach(IAttachment $attachment); |
|
| 38 | + /** |
|
| 39 | + * @param IAttachment $attachment |
|
| 40 | + * @return $this |
|
| 41 | + * @since 13.0.0 |
|
| 42 | + */ |
|
| 43 | + public function attach(IAttachment $attachment); |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * Set the from address of this message. |
|
| 47 | - * |
|
| 48 | - * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php |
|
| 49 | - * |
|
| 50 | - * @param array $addresses Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 51 | - * @return $this |
|
| 52 | - * @since 13.0.0 |
|
| 53 | - */ |
|
| 54 | - public function setFrom(array $addresses); |
|
| 45 | + /** |
|
| 46 | + * Set the from address of this message. |
|
| 47 | + * |
|
| 48 | + * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php |
|
| 49 | + * |
|
| 50 | + * @param array $addresses Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 51 | + * @return $this |
|
| 52 | + * @since 13.0.0 |
|
| 53 | + */ |
|
| 54 | + public function setFrom(array $addresses); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Set the Reply-To address of this message |
|
| 58 | - * |
|
| 59 | - * @param array $addresses |
|
| 60 | - * @return $this |
|
| 61 | - * @since 13.0.0 |
|
| 62 | - */ |
|
| 63 | - public function setReplyTo(array $addresses); |
|
| 56 | + /** |
|
| 57 | + * Set the Reply-To address of this message |
|
| 58 | + * |
|
| 59 | + * @param array $addresses |
|
| 60 | + * @return $this |
|
| 61 | + * @since 13.0.0 |
|
| 62 | + */ |
|
| 63 | + public function setReplyTo(array $addresses); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Set the to addresses of this message. |
|
| 67 | - * |
|
| 68 | - * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 69 | - * @return $this |
|
| 70 | - * @since 13.0.0 |
|
| 71 | - */ |
|
| 72 | - public function setTo(array $recipients); |
|
| 65 | + /** |
|
| 66 | + * Set the to addresses of this message. |
|
| 67 | + * |
|
| 68 | + * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 69 | + * @return $this |
|
| 70 | + * @since 13.0.0 |
|
| 71 | + */ |
|
| 72 | + public function setTo(array $recipients); |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Set the CC recipients of this message. |
|
| 76 | - * |
|
| 77 | - * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 78 | - * @return $this |
|
| 79 | - * @since 13.0.0 |
|
| 80 | - */ |
|
| 81 | - public function setCc(array $recipients); |
|
| 74 | + /** |
|
| 75 | + * Set the CC recipients of this message. |
|
| 76 | + * |
|
| 77 | + * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 78 | + * @return $this |
|
| 79 | + * @since 13.0.0 |
|
| 80 | + */ |
|
| 81 | + public function setCc(array $recipients); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Set the BCC recipients of this message. |
|
| 85 | - * |
|
| 86 | - * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 87 | - * @return $this |
|
| 88 | - * @since 13.0.0 |
|
| 89 | - */ |
|
| 90 | - public function setBcc(array $recipients); |
|
| 83 | + /** |
|
| 84 | + * Set the BCC recipients of this message. |
|
| 85 | + * |
|
| 86 | + * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 87 | + * @return $this |
|
| 88 | + * @since 13.0.0 |
|
| 89 | + */ |
|
| 90 | + public function setBcc(array $recipients); |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * @param IEMailTemplate $emailTemplate |
|
| 94 | - * @return $this |
|
| 95 | - * @since 13.0.0 |
|
| 96 | - */ |
|
| 97 | - public function useTemplate(IEMailTemplate $emailTemplate); |
|
| 92 | + /** |
|
| 93 | + * @param IEMailTemplate $emailTemplate |
|
| 94 | + * @return $this |
|
| 95 | + * @since 13.0.0 |
|
| 96 | + */ |
|
| 97 | + public function useTemplate(IEMailTemplate $emailTemplate); |
|
| 98 | 98 | } |
@@ -34,253 +34,253 @@ |
||
| 34 | 34 | * @package OC\Mail |
| 35 | 35 | */ |
| 36 | 36 | class Message implements IMessage { |
| 37 | - /** @var Swift_Message */ |
|
| 38 | - private $swiftMessage; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @param Swift_Message $swiftMessage |
|
| 42 | - */ |
|
| 43 | - public function __construct(Swift_Message $swiftMessage) { |
|
| 44 | - $this->swiftMessage = $swiftMessage; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @return IAttachment |
|
| 49 | - * @since 13.0.0 |
|
| 50 | - */ |
|
| 51 | - public function createAttachment() { |
|
| 52 | - return new Attachment(\Swift_Attachment::newInstance()); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @param IAttachment $attachment |
|
| 57 | - * @return $this |
|
| 58 | - * @since 13.0.0 |
|
| 59 | - */ |
|
| 60 | - public function attach(IAttachment $attachment) { |
|
| 61 | - /** @var Attachment $attachment */ |
|
| 62 | - $this->swiftMessage->attach($attachment->getSwiftAttachment()); |
|
| 63 | - return $this; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains |
|
| 68 | - * FIXME: Remove this once SwiftMailer supports IDN |
|
| 69 | - * |
|
| 70 | - * @param array $addresses Array of mail addresses, key will get converted |
|
| 71 | - * @return array Converted addresses if `idn_to_ascii` exists |
|
| 72 | - */ |
|
| 73 | - protected function convertAddresses($addresses) { |
|
| 74 | - if (!function_exists('idn_to_ascii')) { |
|
| 75 | - return $addresses; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $convertedAddresses = array(); |
|
| 79 | - |
|
| 80 | - foreach($addresses as $email => $readableName) { |
|
| 81 | - if(!is_numeric($email)) { |
|
| 82 | - list($name, $domain) = explode('@', $email, 2); |
|
| 83 | - $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
|
| 84 | - $convertedAddresses[$name.'@'.$domain] = $readableName; |
|
| 85 | - } else { |
|
| 86 | - list($name, $domain) = explode('@', $readableName, 2); |
|
| 87 | - $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
|
| 88 | - $convertedAddresses[$email] = $name.'@'.$domain; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return $convertedAddresses; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Set the from address of this message. |
|
| 97 | - * |
|
| 98 | - * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php |
|
| 99 | - * |
|
| 100 | - * @param array $addresses Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 101 | - * @return $this |
|
| 102 | - */ |
|
| 103 | - public function setFrom(array $addresses) { |
|
| 104 | - $addresses = $this->convertAddresses($addresses); |
|
| 105 | - |
|
| 106 | - $this->swiftMessage->setFrom($addresses); |
|
| 107 | - return $this; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Get the from address of this message. |
|
| 112 | - * |
|
| 113 | - * @return array |
|
| 114 | - */ |
|
| 115 | - public function getFrom() { |
|
| 116 | - return $this->swiftMessage->getFrom(); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Set the Reply-To address of this message |
|
| 121 | - * |
|
| 122 | - * @param array $addresses |
|
| 123 | - * @return $this |
|
| 124 | - */ |
|
| 125 | - public function setReplyTo(array $addresses) { |
|
| 126 | - $addresses = $this->convertAddresses($addresses); |
|
| 127 | - |
|
| 128 | - $this->swiftMessage->setReplyTo($addresses); |
|
| 129 | - return $this; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Returns the Reply-To address of this message |
|
| 134 | - * |
|
| 135 | - * @return array |
|
| 136 | - */ |
|
| 137 | - public function getReplyTo() { |
|
| 138 | - return $this->swiftMessage->getReplyTo(); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Set the to addresses of this message. |
|
| 143 | - * |
|
| 144 | - * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 145 | - * @return $this |
|
| 146 | - */ |
|
| 147 | - public function setTo(array $recipients) { |
|
| 148 | - $recipients = $this->convertAddresses($recipients); |
|
| 149 | - |
|
| 150 | - $this->swiftMessage->setTo($recipients); |
|
| 151 | - return $this; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Get the to address of this message. |
|
| 156 | - * |
|
| 157 | - * @return array |
|
| 158 | - */ |
|
| 159 | - public function getTo() { |
|
| 160 | - return $this->swiftMessage->getTo(); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - /** |
|
| 164 | - * Set the CC recipients of this message. |
|
| 165 | - * |
|
| 166 | - * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 167 | - * @return $this |
|
| 168 | - */ |
|
| 169 | - public function setCc(array $recipients) { |
|
| 170 | - $recipients = $this->convertAddresses($recipients); |
|
| 171 | - |
|
| 172 | - $this->swiftMessage->setCc($recipients); |
|
| 173 | - return $this; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Get the cc address of this message. |
|
| 178 | - * |
|
| 179 | - * @return array |
|
| 180 | - */ |
|
| 181 | - public function getCc() { |
|
| 182 | - return $this->swiftMessage->getCc(); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Set the BCC recipients of this message. |
|
| 187 | - * |
|
| 188 | - * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 189 | - * @return $this |
|
| 190 | - */ |
|
| 191 | - public function setBcc(array $recipients) { |
|
| 192 | - $recipients = $this->convertAddresses($recipients); |
|
| 193 | - |
|
| 194 | - $this->swiftMessage->setBcc($recipients); |
|
| 195 | - return $this; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /** |
|
| 199 | - * Get the Bcc address of this message. |
|
| 200 | - * |
|
| 201 | - * @return array |
|
| 202 | - */ |
|
| 203 | - public function getBcc() { |
|
| 204 | - return $this->swiftMessage->getBcc(); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Set the subject of this message. |
|
| 209 | - * |
|
| 210 | - * @param $subject |
|
| 211 | - * @return $this |
|
| 212 | - */ |
|
| 213 | - public function setSubject($subject) { |
|
| 214 | - $this->swiftMessage->setSubject($subject); |
|
| 215 | - return $this; |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Get the from subject of this message. |
|
| 220 | - * |
|
| 221 | - * @return string |
|
| 222 | - */ |
|
| 223 | - public function getSubject() { |
|
| 224 | - return $this->swiftMessage->getSubject(); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - /** |
|
| 228 | - * Set the plain-text body of this message. |
|
| 229 | - * |
|
| 230 | - * @param string $body |
|
| 231 | - * @return $this |
|
| 232 | - */ |
|
| 233 | - public function setPlainBody($body) { |
|
| 234 | - $this->swiftMessage->setBody($body); |
|
| 235 | - return $this; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Get the plain body of this message. |
|
| 240 | - * |
|
| 241 | - * @return string |
|
| 242 | - */ |
|
| 243 | - public function getPlainBody() { |
|
| 244 | - return $this->swiftMessage->getBody(); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Set the HTML body of this message. Consider also sending a plain-text body instead of only an HTML one. |
|
| 249 | - * |
|
| 250 | - * @param string $body |
|
| 251 | - * @return $this |
|
| 252 | - */ |
|
| 253 | - public function setHtmlBody($body) { |
|
| 254 | - $this->swiftMessage->addPart($body, 'text/html'); |
|
| 255 | - return $this; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Get's the underlying SwiftMessage |
|
| 260 | - * @return Swift_Message |
|
| 261 | - */ |
|
| 262 | - public function getSwiftMessage() { |
|
| 263 | - return $this->swiftMessage; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * @param string $body |
|
| 268 | - * @param string $contentType |
|
| 269 | - * @return $this |
|
| 270 | - */ |
|
| 271 | - public function setBody($body, $contentType) { |
|
| 272 | - $this->swiftMessage->setBody($body, $contentType); |
|
| 273 | - return $this; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @param IEMailTemplate $emailTemplate |
|
| 278 | - * @return $this |
|
| 279 | - */ |
|
| 280 | - public function useTemplate(IEMailTemplate $emailTemplate) { |
|
| 281 | - $this->setSubject($emailTemplate->renderSubject()); |
|
| 282 | - $this->setPlainBody($emailTemplate->renderText()); |
|
| 283 | - $this->setHtmlBody($emailTemplate->renderHtml()); |
|
| 284 | - return $this; |
|
| 285 | - } |
|
| 37 | + /** @var Swift_Message */ |
|
| 38 | + private $swiftMessage; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @param Swift_Message $swiftMessage |
|
| 42 | + */ |
|
| 43 | + public function __construct(Swift_Message $swiftMessage) { |
|
| 44 | + $this->swiftMessage = $swiftMessage; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @return IAttachment |
|
| 49 | + * @since 13.0.0 |
|
| 50 | + */ |
|
| 51 | + public function createAttachment() { |
|
| 52 | + return new Attachment(\Swift_Attachment::newInstance()); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param IAttachment $attachment |
|
| 57 | + * @return $this |
|
| 58 | + * @since 13.0.0 |
|
| 59 | + */ |
|
| 60 | + public function attach(IAttachment $attachment) { |
|
| 61 | + /** @var Attachment $attachment */ |
|
| 62 | + $this->swiftMessage->attach($attachment->getSwiftAttachment()); |
|
| 63 | + return $this; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * SwiftMailer does currently not work with IDN domains, this function therefore converts the domains |
|
| 68 | + * FIXME: Remove this once SwiftMailer supports IDN |
|
| 69 | + * |
|
| 70 | + * @param array $addresses Array of mail addresses, key will get converted |
|
| 71 | + * @return array Converted addresses if `idn_to_ascii` exists |
|
| 72 | + */ |
|
| 73 | + protected function convertAddresses($addresses) { |
|
| 74 | + if (!function_exists('idn_to_ascii')) { |
|
| 75 | + return $addresses; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $convertedAddresses = array(); |
|
| 79 | + |
|
| 80 | + foreach($addresses as $email => $readableName) { |
|
| 81 | + if(!is_numeric($email)) { |
|
| 82 | + list($name, $domain) = explode('@', $email, 2); |
|
| 83 | + $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
|
| 84 | + $convertedAddresses[$name.'@'.$domain] = $readableName; |
|
| 85 | + } else { |
|
| 86 | + list($name, $domain) = explode('@', $readableName, 2); |
|
| 87 | + $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
|
| 88 | + $convertedAddresses[$email] = $name.'@'.$domain; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $convertedAddresses; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Set the from address of this message. |
|
| 97 | + * |
|
| 98 | + * If no "From" address is used \OC\Mail\Mailer will use mail_from_address and mail_domain from config.php |
|
| 99 | + * |
|
| 100 | + * @param array $addresses Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 101 | + * @return $this |
|
| 102 | + */ |
|
| 103 | + public function setFrom(array $addresses) { |
|
| 104 | + $addresses = $this->convertAddresses($addresses); |
|
| 105 | + |
|
| 106 | + $this->swiftMessage->setFrom($addresses); |
|
| 107 | + return $this; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Get the from address of this message. |
|
| 112 | + * |
|
| 113 | + * @return array |
|
| 114 | + */ |
|
| 115 | + public function getFrom() { |
|
| 116 | + return $this->swiftMessage->getFrom(); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Set the Reply-To address of this message |
|
| 121 | + * |
|
| 122 | + * @param array $addresses |
|
| 123 | + * @return $this |
|
| 124 | + */ |
|
| 125 | + public function setReplyTo(array $addresses) { |
|
| 126 | + $addresses = $this->convertAddresses($addresses); |
|
| 127 | + |
|
| 128 | + $this->swiftMessage->setReplyTo($addresses); |
|
| 129 | + return $this; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Returns the Reply-To address of this message |
|
| 134 | + * |
|
| 135 | + * @return array |
|
| 136 | + */ |
|
| 137 | + public function getReplyTo() { |
|
| 138 | + return $this->swiftMessage->getReplyTo(); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Set the to addresses of this message. |
|
| 143 | + * |
|
| 144 | + * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 145 | + * @return $this |
|
| 146 | + */ |
|
| 147 | + public function setTo(array $recipients) { |
|
| 148 | + $recipients = $this->convertAddresses($recipients); |
|
| 149 | + |
|
| 150 | + $this->swiftMessage->setTo($recipients); |
|
| 151 | + return $this; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Get the to address of this message. |
|
| 156 | + * |
|
| 157 | + * @return array |
|
| 158 | + */ |
|
| 159 | + public function getTo() { |
|
| 160 | + return $this->swiftMessage->getTo(); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + /** |
|
| 164 | + * Set the CC recipients of this message. |
|
| 165 | + * |
|
| 166 | + * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 167 | + * @return $this |
|
| 168 | + */ |
|
| 169 | + public function setCc(array $recipients) { |
|
| 170 | + $recipients = $this->convertAddresses($recipients); |
|
| 171 | + |
|
| 172 | + $this->swiftMessage->setCc($recipients); |
|
| 173 | + return $this; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Get the cc address of this message. |
|
| 178 | + * |
|
| 179 | + * @return array |
|
| 180 | + */ |
|
| 181 | + public function getCc() { |
|
| 182 | + return $this->swiftMessage->getCc(); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Set the BCC recipients of this message. |
|
| 187 | + * |
|
| 188 | + * @param array $recipients Example: array('[email protected]', '[email protected]' => 'A name') |
|
| 189 | + * @return $this |
|
| 190 | + */ |
|
| 191 | + public function setBcc(array $recipients) { |
|
| 192 | + $recipients = $this->convertAddresses($recipients); |
|
| 193 | + |
|
| 194 | + $this->swiftMessage->setBcc($recipients); |
|
| 195 | + return $this; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + /** |
|
| 199 | + * Get the Bcc address of this message. |
|
| 200 | + * |
|
| 201 | + * @return array |
|
| 202 | + */ |
|
| 203 | + public function getBcc() { |
|
| 204 | + return $this->swiftMessage->getBcc(); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Set the subject of this message. |
|
| 209 | + * |
|
| 210 | + * @param $subject |
|
| 211 | + * @return $this |
|
| 212 | + */ |
|
| 213 | + public function setSubject($subject) { |
|
| 214 | + $this->swiftMessage->setSubject($subject); |
|
| 215 | + return $this; |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Get the from subject of this message. |
|
| 220 | + * |
|
| 221 | + * @return string |
|
| 222 | + */ |
|
| 223 | + public function getSubject() { |
|
| 224 | + return $this->swiftMessage->getSubject(); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + /** |
|
| 228 | + * Set the plain-text body of this message. |
|
| 229 | + * |
|
| 230 | + * @param string $body |
|
| 231 | + * @return $this |
|
| 232 | + */ |
|
| 233 | + public function setPlainBody($body) { |
|
| 234 | + $this->swiftMessage->setBody($body); |
|
| 235 | + return $this; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Get the plain body of this message. |
|
| 240 | + * |
|
| 241 | + * @return string |
|
| 242 | + */ |
|
| 243 | + public function getPlainBody() { |
|
| 244 | + return $this->swiftMessage->getBody(); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * Set the HTML body of this message. Consider also sending a plain-text body instead of only an HTML one. |
|
| 249 | + * |
|
| 250 | + * @param string $body |
|
| 251 | + * @return $this |
|
| 252 | + */ |
|
| 253 | + public function setHtmlBody($body) { |
|
| 254 | + $this->swiftMessage->addPart($body, 'text/html'); |
|
| 255 | + return $this; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Get's the underlying SwiftMessage |
|
| 260 | + * @return Swift_Message |
|
| 261 | + */ |
|
| 262 | + public function getSwiftMessage() { |
|
| 263 | + return $this->swiftMessage; |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * @param string $body |
|
| 268 | + * @param string $contentType |
|
| 269 | + * @return $this |
|
| 270 | + */ |
|
| 271 | + public function setBody($body, $contentType) { |
|
| 272 | + $this->swiftMessage->setBody($body, $contentType); |
|
| 273 | + return $this; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @param IEMailTemplate $emailTemplate |
|
| 278 | + * @return $this |
|
| 279 | + */ |
|
| 280 | + public function useTemplate(IEMailTemplate $emailTemplate) { |
|
| 281 | + $this->setSubject($emailTemplate->renderSubject()); |
|
| 282 | + $this->setPlainBody($emailTemplate->renderText()); |
|
| 283 | + $this->setHtmlBody($emailTemplate->renderHtml()); |
|
| 284 | + return $this; |
|
| 285 | + } |
|
| 286 | 286 | } |
@@ -31,48 +31,48 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class Attachment implements IAttachment { |
| 33 | 33 | |
| 34 | - /** @var \Swift_Mime_Attachment */ |
|
| 35 | - protected $swiftAttachment; |
|
| 34 | + /** @var \Swift_Mime_Attachment */ |
|
| 35 | + protected $swiftAttachment; |
|
| 36 | 36 | |
| 37 | - public function __construct(\Swift_Mime_Attachment $attachment) { |
|
| 38 | - $this->swiftAttachment = $attachment; |
|
| 39 | - } |
|
| 37 | + public function __construct(\Swift_Mime_Attachment $attachment) { |
|
| 38 | + $this->swiftAttachment = $attachment; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param string $filename |
|
| 43 | - * @return $this |
|
| 44 | - * @since 13.0.0 |
|
| 45 | - */ |
|
| 46 | - public function setFilename($filename) { |
|
| 47 | - $this->swiftAttachment->setFilename($filename); |
|
| 48 | - return $this; |
|
| 49 | - } |
|
| 41 | + /** |
|
| 42 | + * @param string $filename |
|
| 43 | + * @return $this |
|
| 44 | + * @since 13.0.0 |
|
| 45 | + */ |
|
| 46 | + public function setFilename($filename) { |
|
| 47 | + $this->swiftAttachment->setFilename($filename); |
|
| 48 | + return $this; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @param string $contentType |
|
| 53 | - * @return $this |
|
| 54 | - * @since 13.0.0 |
|
| 55 | - */ |
|
| 56 | - public function setContentType($contentType) { |
|
| 57 | - $this->swiftAttachment->setContentType($contentType); |
|
| 58 | - return $this; |
|
| 59 | - } |
|
| 51 | + /** |
|
| 52 | + * @param string $contentType |
|
| 53 | + * @return $this |
|
| 54 | + * @since 13.0.0 |
|
| 55 | + */ |
|
| 56 | + public function setContentType($contentType) { |
|
| 57 | + $this->swiftAttachment->setContentType($contentType); |
|
| 58 | + return $this; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @param string $body |
|
| 63 | - * @return $this |
|
| 64 | - * @since 13.0.0 |
|
| 65 | - */ |
|
| 66 | - public function setBody($body) { |
|
| 67 | - $this->swiftAttachment->setBody($body); |
|
| 68 | - return $this; |
|
| 69 | - } |
|
| 61 | + /** |
|
| 62 | + * @param string $body |
|
| 63 | + * @return $this |
|
| 64 | + * @since 13.0.0 |
|
| 65 | + */ |
|
| 66 | + public function setBody($body) { |
|
| 67 | + $this->swiftAttachment->setBody($body); |
|
| 68 | + return $this; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @return \Swift_Mime_Attachment |
|
| 73 | - */ |
|
| 74 | - public function getSwiftAttachment() { |
|
| 75 | - return $this->swiftAttachment; |
|
| 76 | - } |
|
| 71 | + /** |
|
| 72 | + * @return \Swift_Mime_Attachment |
|
| 73 | + */ |
|
| 74 | + public function getSwiftAttachment() { |
|
| 75 | + return $this->swiftAttachment; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | } |