IMessage.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Mail\Provider;
  8. /**
  9. * Mail Message Interface
  10. *
  11. * This interface is a base requirement of methods and functionality used to construct a mail message object
  12. *
  13. * @since 30.0.0
  14. *
  15. */
  16. interface IMessage {
  17. /**
  18. * arbitrary unique text string identifying this message
  19. *
  20. * @since 30.0.0
  21. *
  22. * @return string id of this message
  23. */
  24. public function id(): string;
  25. /**
  26. * sets the sender of this message
  27. *
  28. * @since 30.0.0
  29. *
  30. * @param IAddress $value sender's mail address object
  31. *
  32. * @return self return this object for command chaining
  33. */
  34. public function setFrom(IAddress $value): self;
  35. /**
  36. * gets the sender of this message
  37. *
  38. * @since 30.0.0
  39. *
  40. * @return IAddress|null sender's mail address object
  41. */
  42. public function getFrom(): IAddress|null;
  43. /**
  44. * sets the sender's reply to address of this message
  45. *
  46. * @since 30.0.0
  47. *
  48. * @param IAddress $value senders's reply to mail address object
  49. *
  50. * @return self return this object for command chaining
  51. */
  52. public function setReplyTo(IAddress $value): self;
  53. /**
  54. * gets the sender's reply to address of this message
  55. *
  56. * @since 30.0.0
  57. *
  58. * @return IAddress|null sender's reply to mail address object
  59. */
  60. public function getReplyTo(): IAddress|null;
  61. /**
  62. * sets the recipient(s) of this message
  63. *
  64. * @since 30.0.0
  65. *
  66. * @param IAddress ...$value collection of or one or more mail address objects
  67. *
  68. * @return self return this object for command chaining
  69. */
  70. public function setTo(IAddress ...$value): self;
  71. /**
  72. * gets the recipient(s) of this message
  73. *
  74. * @since 30.0.0
  75. *
  76. * @return array<int,IAddress> collection of all recipient mail address objects
  77. */
  78. public function getTo(): array;
  79. /**
  80. * sets the copy to recipient(s) of this message
  81. *
  82. * @since 30.0.0
  83. *
  84. * @param IAddress ...$value collection of or one or more mail address objects
  85. *
  86. * @return self return this object for command chaining
  87. */
  88. public function setCc(IAddress ...$value): self;
  89. /**
  90. * gets the copy to recipient(s) of this message
  91. *
  92. * @since 30.0.0
  93. *
  94. * @return array<int,IAddress> collection of all copied recipient mail address objects
  95. */
  96. public function getCc(): array;
  97. /**
  98. * sets the blind copy to recipient(s) of this message
  99. *
  100. * @since 30.0.0
  101. *
  102. * @param IAddress ...$value collection of or one or more mail address objects
  103. *
  104. * @return self return this object for command chaining
  105. */
  106. public function setBcc(IAddress ...$value): self;
  107. /**
  108. * gets the blind copy to recipient(s) of this message
  109. *
  110. * @since 30.0.0
  111. *
  112. * @return array<int,IAddress> collection of all blind copied recipient mail address objects
  113. */
  114. public function getBcc(): array;
  115. /**
  116. * sets the subject of this message
  117. *
  118. * @since 30.0.0
  119. *
  120. * @param string $value subject of mail message
  121. *
  122. * @return self return this object for command chaining
  123. */
  124. public function setSubject(string $value): self;
  125. /**
  126. * gets the subject of this message
  127. *
  128. * @since 30.0.0
  129. *
  130. * @return string|null subject of message or null if one is not set
  131. */
  132. public function getSubject(): string|null;
  133. /**
  134. * sets the plain text or html body of this message
  135. *
  136. * @since 30.0.0
  137. *
  138. * @param string $value text or html body of message
  139. * @param bool $html html flag - true for html
  140. *
  141. * @return self return this object for command chaining
  142. */
  143. public function setBody(string $value, bool $html): self;
  144. /**
  145. * gets either the html or plain text body of this message
  146. *
  147. * html body will be returned over plain text if html body exists
  148. *
  149. * @since 30.0.0
  150. *
  151. * @return string|null html/plain body of this message or null if one is not set
  152. */
  153. public function getBody(): string|null;
  154. /**
  155. * sets the html body of this message
  156. *
  157. * @since 30.0.0
  158. *
  159. * @param string $value html body of message
  160. *
  161. * @return self return this object for command chaining
  162. */
  163. public function setBodyHtml(string $value): self;
  164. /**
  165. * gets the html body of this message
  166. *
  167. * @since 30.0.0
  168. *
  169. * @return string|null html body of this message or null if one is not set
  170. */
  171. public function getBodyHtml(): string|null;
  172. /**
  173. * sets the plain text body of this message
  174. *
  175. * @since 30.0.0
  176. *
  177. * @param string $value plain text body of message
  178. *
  179. * @return self return this object for command chaining
  180. */
  181. public function setBodyPlain(string $value): self;
  182. /**
  183. * gets the plain text body of this message
  184. *
  185. * @since 30.0.0
  186. *
  187. * @return string|null plain text body of this message or null if one is not set
  188. */
  189. public function getBodyPlain(): string|null;
  190. /**
  191. * sets the attachments of this message
  192. *
  193. * @since 30.0.0
  194. *
  195. * @param IAttachment ...$value collection of or one or more mail attachment objects
  196. *
  197. * @return self return this object for command chaining
  198. */
  199. public function setAttachments(IAttachment ...$value): self;
  200. /**
  201. * gets the attachments of this message
  202. *
  203. * @since 30.0.0
  204. *
  205. * @return array<int,IAttachment> collection of all mail attachment objects
  206. */
  207. public function getAttachments(): array;
  208. }