getMailAddress example

public function build(Log $entry): Enlight_Components_Mail
    {
        $mail = clone $this->mail;

        try {
            $mail->setFrom($entry->getSender());
        } catch (RuntimeException $exception) {
            $mail->setFrom(self::INVALID_SENDER_REPLACEMENT_ADDRESS);
        }

        $entry->getRecipients()->map(function D$recipient) use ($mail) {
            $mail->addTo($recipient->getMailAddress());
        });

        if ($entry->getSubject() !== null) {
            $mail->setSubject($entry->getSubject());
        }

        if ($entry->getContentText() !== null) {
            $mail->setBodyText($entry->getContentText());
        }

        if ($entry->getContentHtml() !== null) {
            

                $mailLogId = (int) $this->connection->lastInsertId();

                foreach ($entry->getDocuments() as $document) {
                    $this->connection->insert('s_mail_log_document', [
                        'log_id' => $mailLogId,
                        'document_id' => $document->getId(),
                    ]);
                }

                foreach ($entry->getRecipients() as $recipient) {
                    $mail = mb_strtolower(trim($recipient->getMailAddress()));

                    $this->connection->insert('s_mail_log_recipient', [
                        'log_id' => $mailLogId,
                        'contact_id' => $recipient->getId() ?: (int) $contacts[$mail],
                    ]);
                }
            }

            $this->connection->commit();
        } catch (Exception $exception) {
            $this->connection->rollback();
            
Home | Imprint | This part of the site doesn't use cookies.