No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

219 líneas
6.9KB

  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\mail;
  8. /**
  9. * MessageInterface is the interface that should be implemented by mail message classes.
  10. *
  11. * A message represents the settings and content of an email, such as the sender, recipient,
  12. * subject, body, etc.
  13. *
  14. * Messages are sent by a [[\yii\mail\MailerInterface|mailer]], like the following,
  15. *
  16. * ```php
  17. * Yii::$app->mailer->compose()
  18. * ->setFrom('from@domain.com')
  19. * ->setTo($form->email)
  20. * ->setSubject($form->subject)
  21. * ->setTextBody('Plain text content')
  22. * ->setHtmlBody('<b>HTML content</b>')
  23. * ->send();
  24. * ```
  25. *
  26. * @see MailerInterface
  27. *
  28. * @author Paul Klimov <klimov.paul@gmail.com>
  29. * @since 2.0
  30. */
  31. interface MessageInterface
  32. {
  33. /**
  34. * Returns the character set of this message.
  35. * @return string the character set of this message.
  36. */
  37. public function getCharset();
  38. /**
  39. * Sets the character set of this message.
  40. * @param string $charset character set name.
  41. * @return $this self reference.
  42. */
  43. public function setCharset($charset);
  44. /**
  45. * Returns the message sender.
  46. * @return string the sender
  47. */
  48. public function getFrom();
  49. /**
  50. * Sets the message sender.
  51. * @param string|array $from sender email address.
  52. * You may pass an array of addresses if this message is from multiple people.
  53. * You may also specify sender name in addition to email address using format:
  54. * `[email => name]`.
  55. * @return $this self reference.
  56. */
  57. public function setFrom($from);
  58. /**
  59. * Returns the message recipient(s).
  60. * @return array the message recipients
  61. */
  62. public function getTo();
  63. /**
  64. * Sets the message recipient(s).
  65. * @param string|array $to receiver email address.
  66. * You may pass an array of addresses if multiple recipients should receive this message.
  67. * You may also specify receiver name in addition to email address using format:
  68. * `[email => name]`.
  69. * @return $this self reference.
  70. */
  71. public function setTo($to);
  72. /**
  73. * Returns the reply-to address of this message.
  74. * @return string the reply-to address of this message.
  75. */
  76. public function getReplyTo();
  77. /**
  78. * Sets the reply-to address of this message.
  79. * @param string|array $replyTo the reply-to address.
  80. * You may pass an array of addresses if this message should be replied to multiple people.
  81. * You may also specify reply-to name in addition to email address using format:
  82. * `[email => name]`.
  83. * @return $this self reference.
  84. */
  85. public function setReplyTo($replyTo);
  86. /**
  87. * Returns the Cc (additional copy receiver) addresses of this message.
  88. * @return array the Cc (additional copy receiver) addresses of this message.
  89. */
  90. public function getCc();
  91. /**
  92. * Sets the Cc (additional copy receiver) addresses of this message.
  93. * @param string|array $cc copy receiver email address.
  94. * You may pass an array of addresses if multiple recipients should receive this message.
  95. * You may also specify receiver name in addition to email address using format:
  96. * `[email => name]`.
  97. * @return $this self reference.
  98. */
  99. public function setCc($cc);
  100. /**
  101. * Returns the Bcc (hidden copy receiver) addresses of this message.
  102. * @return array the Bcc (hidden copy receiver) addresses of this message.
  103. */
  104. public function getBcc();
  105. /**
  106. * Sets the Bcc (hidden copy receiver) addresses of this message.
  107. * @param string|array $bcc hidden copy receiver email address.
  108. * You may pass an array of addresses if multiple recipients should receive this message.
  109. * You may also specify receiver name in addition to email address using format:
  110. * `[email => name]`.
  111. * @return $this self reference.
  112. */
  113. public function setBcc($bcc);
  114. /**
  115. * Returns the message subject.
  116. * @return string the message subject
  117. */
  118. public function getSubject();
  119. /**
  120. * Sets the message subject.
  121. * @param string $subject message subject
  122. * @return $this self reference.
  123. */
  124. public function setSubject($subject);
  125. /**
  126. * Sets message plain text content.
  127. * @param string $text message plain text content.
  128. * @return $this self reference.
  129. */
  130. public function setTextBody($text);
  131. /**
  132. * Sets message HTML content.
  133. * @param string $html message HTML content.
  134. * @return $this self reference.
  135. */
  136. public function setHtmlBody($html);
  137. /**
  138. * Attaches existing file to the email message.
  139. * @param string $fileName full file name
  140. * @param array $options options for embed file. Valid options are:
  141. *
  142. * - fileName: name, which should be used to attach file.
  143. * - contentType: attached file MIME type.
  144. *
  145. * @return $this self reference.
  146. */
  147. public function attach($fileName, array $options = []);
  148. /**
  149. * Attach specified content as file for the email message.
  150. * @param string $content attachment file content.
  151. * @param array $options options for embed file. Valid options are:
  152. *
  153. * - fileName: name, which should be used to attach file.
  154. * - contentType: attached file MIME type.
  155. *
  156. * @return $this self reference.
  157. */
  158. public function attachContent($content, array $options = []);
  159. /**
  160. * Attach a file and return it's CID source.
  161. * This method should be used when embedding images or other data in a message.
  162. * @param string $fileName file name.
  163. * @param array $options options for embed file. Valid options are:
  164. *
  165. * - fileName: name, which should be used to attach file.
  166. * - contentType: attached file MIME type.
  167. *
  168. * @return string attachment CID.
  169. */
  170. public function embed($fileName, array $options = []);
  171. /**
  172. * Attach a content as file and return it's CID source.
  173. * This method should be used when embedding images or other data in a message.
  174. * @param string $content attachment file content.
  175. * @param array $options options for embed file. Valid options are:
  176. *
  177. * - fileName: name, which should be used to attach file.
  178. * - contentType: attached file MIME type.
  179. *
  180. * @return string attachment CID.
  181. */
  182. public function embedContent($content, array $options = []);
  183. /**
  184. * Sends this email message.
  185. * @param MailerInterface $mailer the mailer that should be used to send this message.
  186. * If null, the "mail" application component will be used instead.
  187. * @return boolean whether this message is sent successfully.
  188. */
  189. public function send(MailerInterface $mailer = null);
  190. /**
  191. * Returns string representation of this message.
  192. * @return string the string representation of this message.
  193. */
  194. public function toString();
  195. }