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->fromEmail = $fromEmail;
42 $this->replyTo = $replyTo;
43 $this->toEmail = $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 getFromEmail()
64 return $this->fromEmail;
70 public function getReplyTo()
72 return $this->replyTo;
78 public function getToEmail()
80 return $this->toEmail;
86 public function getSubject()
88 return $this->subject;
94 public function getMessage(bool $text = 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->toEmail = $email;
131 $newEmail->toUid = $uid;