/** * @param $email * @param string $reason * @param bool $flush */ public function setBounceDoNotContact($email, $reason = '', $flush = true) { $repo = $this->getRepository(); if (!$repo->checkDoNotEmail($email)) { $dnc = new DoNotEmail(); $dnc->setEmailAddress($email); $dnc->setDateAdded(new \DateTime()); $dnc->setBounced(); $dnc->setComments($reason); $em = $this->factory->getEntityManager(); $em->persist($dnc); if ($flush) { $em->flush(); } } }
/** * Add a do not contact entry for the lead * * @param Lead $lead * @param string $emailAddress * @param string $reason * @param bool|true $persist * @param bool|false $manual * * @return DoNotEmail|bool * @throws \Doctrine\DBAL\DBALException */ public function setDoNotContact(Lead $lead, $emailAddress = '', $reason = '', $persist = true, $manual = false) { if (empty($emailAddress)) { $emailAddress = $lead->getEmail(); if (empty($emailAddress)) { return false; } } $em = $this->factory->getEntityManager(); $repo = $em->getRepository('MauticEmailBundle:Email'); if (!$repo->checkDoNotEmail($emailAddress)) { $dnc = new DoNotEmail(); $dnc->setLead($lead); $dnc->setEmailAddress($emailAddress); $dnc->setDateAdded(new \DateTime()); $dnc->setUnsubscribed(); $dnc->setManual($manual); $dnc->setComments($reason); if ($persist) { $repo->saveEntity($dnc); } else { $lead->addDoNotEmailEntry($dnc); return $dnc; } } return false; }
/** * {@inheritDoc} */ public function setComments($comments) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setComments', array($comments)); return parent::setComments($comments); }
/** * Add a do not contact entry for the lead * * @param Lead $lead * @param string $emailAddress * @param string $reason * @param bool $persist */ public function setDoNotContact(Lead $lead, $emailAddress = '', $reason = '', $persist = true) { if (empty($emailAddress)) { $fields = $lead->getFields(); $emailAddress = $fields['core']['email']['value']; if (empty($emailAddress)) { return; } } $em = $this->factory->getEntityManager(); $repo = $em->getRepository('MauticEmailBundle:Email'); if (!$repo->checkDoNotEmail($emailAddress)) { $dnc = new DoNotEmail(); $dnc->setLead($lead); $dnc->setEmailAddress($emailAddress); $dnc->setDateAdded(new \DateTime()); $dnc->setUnsubscribed(); $dnc->setComments($reason); if ($persist) { $repo->saveEntity($dnc); } else { return $dnc; } } }