コード例 #1
0
 /**
  * Create EmailUser entity object
  *
  * @param string               $subject             The email subject
  * @param string $from                              The FROM email address,
  *                                                  for example: john@example.com or "John Smith" <john@example.c4m>
  * @param string|string[]|null $to                  The TO email address(es).
  *                                                  Example of email address see in description of $from parameter
  * @param \DateTime            $sentAt              The date/time when email sent
  * @param \DateTime            $receivedAt          The date/time when email received
  * @param \DateTime            $internalDate        The date/time an email server returned in INTERNALDATE field
  * @param integer $importance                       The email importance flag.
  *                                                  Can be one of *_IMPORTANCE constants of Email class
  * @param string|string[]|null $cc                  The CC email address(es).
  *                                                  Example of email address see in description of $from parameter
  * @param string|string[]|null $bcc                 The BCC email address(es).
  *                                                  Example of email address see in description of $from parameter
  * @param User|Mailbox|null $owner                  Owner of the email
  * @param OrganizationInterface|null $organization
  *
  * @return EmailUser
  *
  * @SuppressWarnings(ExcessiveParameterList)
  */
 public function emailUser($subject, $from, $to, $sentAt, $receivedAt, $internalDate, $importance = Email::NORMAL_IMPORTANCE, $cc = null, $bcc = null, $owner = null, $organization = null)
 {
     $emailUser = new EmailUser();
     $email = $this->email($subject, $from, $to, $sentAt, $internalDate, $importance, $cc, $bcc);
     $emailUser->setReceivedAt($receivedAt);
     $emailUser->setEmail($email);
     if ($owner !== null) {
         if ($owner instanceof User) {
             $emailUser->setOwner($owner);
         } elseif ($owner instanceof Mailbox) {
             $emailUser->setMailboxOwner($owner);
         }
     }
     if ($organization !== null) {
         $emailUser->setOrganization($organization);
     } elseif ($owner !== null) {
         $emailUser->setOrganization($owner->getOrganization());
     }
     $this->batch->addEmailUser($emailUser);
     return $emailUser;
 }