3 namespace Friendica\Object;
5 use Friendica\Object\EMail\IEmail;
8 * The default implementation of the IEmail interface
10 * Provides the possibility to reuse the email instance with new recipients (@see Email::withRecipient())
12 class Email implements IEmail
32 private $additionalMailHeader = '';
34 private $toUid = null;
36 public function __construct(string $fromName, string $fromEmail, string $replyTo, string $toEmail,
37 string $subject, string $msgHtml, string $msgText,
38 string $additionalMailHeader = '', int $toUid = null)
40 $this->fromName = $fromName;
41 $this->fromAddress = $fromEmail;
42 $this->replyTo = $replyTo;
43 $this->toAddress = $toEmail;
44 $this->subject = $subject;
45 $this->msgHtml = $msgHtml;
46 $this->msgText = $msgText;
47 $this->additionalMailHeader = $additionalMailHeader;
48 $this->toUid = $toUid;
54 public function getFromName()
56 return $this->fromName;
62 public function getFromAddress()
64 return $this->fromAddress;
70 public function getReplyTo()
72 return $this->replyTo;
78 public function getToAddress()
80 return $this->toAddress;
86 public function getSubject()
88 return $this->subject;
94 public function getMessage(bool $plain = false)
97 return $this->msgText;
99 return $this->msgHtml;
106 public function getAdditionalMailHeader()
108 return $this->additionalMailHeader;
114 public function getRecipientUid()
120 * Returns the current email with a new recipient
122 * @param string $email The email of the recipient
123 * @param int $uid The (optional) UID of the recipient for further infos
127 public function withRecipient(string $email, int $uid = null)
129 $newEmail = clone $this;
130 $newEmail->toAddress = $email;
131 $newEmail->toUid = $uid;