E-mail the results of the scheduled operation.

@param  array|mixed $addresses
@param  bool        $onlyIfOutputExists
@return $this

@throws \LogicException
324114
public function emailOutputTo($addresses, $onlyIfOutputExists = false)
    {
        $this->ensureOutputIsBeingCapturedForEmail();

        $addresses = Arr::wrap($addresses);

        return $this->then(
            function (Mailer $mailer) use ($addresses, $onlyIfOutputExists) {
                $this->emailOutput($mailer, $addresses, $onlyIfOutputExists);
            }
        );
    }
1053725
private function isAddressComplete($address)
    {
        foreach ($this->requiredAddressFields as $field) {
            if (empty($address[$field])) {
                return false;
            }
        }
        return true;
    }
1050781
public function removeAddresses($addresses)
    {
        $this->setCachedValue(null);
        foreach ((array) $addresses as $address) {
            unset($this->mailboxes[$address]);
        }
    }
480469
public function deleteEmailAddress(array $addresses = []): bool
    {
        $this->getApi()->request($this->getApi()->sprintf('/user/emails'), Request::METHOD_DELETE, $addresses);

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
184974
public function setStates($objects, $processes, $onlySuccess)
    {
        $objects = ( ! is_array($objects) && ! $objects instanceof \ArrayAccess) ? array($objects) : $objects;

        if (0 === count($objects)) {
            return;
        }

        $ordersIndexedByWorkflowIdentifier = array();
        foreach ($objects as $object) {
            if (!$object instanceof ModelStateInterface) {
                throw new \InvalidArgumentException();
            }

            $ordersIndexedByWorkflowIdentifier[$object->getWorkflowIdentifier()] = $object;
        }

        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('ms')
            ->from('Lexik\Bundle\WorkflowBundle\Entity\ModelState', 'ms')
            ->andWhere($qb->expr()->in('ms.workflowIdentifier', array_keys($ordersIndexedByWorkflowIdentifier)))
            ->orderBy('ms.id');

        if (count($processes)) {
            $qb->andWhere($qb->expr()->in('ms.processName', $processes));
        }

        if ($onlySuccess) {
            $qb->andWhere('ms.successful = 1');
        }

        $states = $qb->getQuery()->getResult();

        foreach ($states as $state) {
            $ordersIndexedByWorkflowIdentifier[$state->getWorkflowIdentifier()]->addState($state);
        }
    }
428861
public function replyTo($address, $name = null)
    {
        if (is_array($address)) {
            $this->addAddressArray($address, 'replyTo');
        } else {
            $this->reply_to[$address] = $name;
        }

        return $this;
    }
64496
private function setAddressEmbeddable(
        AddressEmbeddableInterface $address,
        bool $notify = true
    ): self {
        $this->addressEmbeddable = $address;
        $this->addressEmbeddable->setOwningEntity($this);
        if (true === $notify) {
            $this->notifyEmbeddablePrefixedProperties(
                HasAddressEmbeddableInterface::PROP_ADDRESS_EMBEDDABLE
            );
        }

        return $this;
    }
980824
public function setSendAsAlias($domain, $user, $name, $address, $replyTo = null, $makeDefault = false)
    {
        $url = self::BASE_URL . "{$domain}/{$user}/sendas";
        $request = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">
    <apps:property name="name" value="{$name}" />
    <apps:property name="address" value="{$address}" />
XML;
        if ($replyTo !== null) {
            $request .= "<apps:property name=\"replyTo\" value=\"{$replyTo}\" />";
        }
        if ($makeDefault) {
            $request .= "<apps:property name=\"makeDefault\" value=\"true\" />";
        }
        $request .= "</atom:entry>";
        $request = new \Google_Http_Request($url, 'POST', array('Content-Type' => 'application/atom+xml'),
           $request);

        $httpRequest = $this->helper->getClient()
           ->getAuth()
           ->authenticatedRequest($request);

        return ($httpRequest->getResponseHttpCode() == 201);
    }
534089
public static function create(string $template, $recipients, Address $sender = null)
    {
        $email = new static($template);

        $recipients = is_array($recipients) ? $recipients : [$recipients];
        foreach ($recipients as $recipient) {
            $email->addRecipient($recipient);
        }

        if (null !== $sender) {
            $email->setSender($sender);
        }

        return $email;
    }
1329752
public function setFrom(array $addresses): Email
    {
        $addresses = $this->transformAddressesToArray($addresses);
        $this->message->setFrom($addresses);

        return $this;
    }
900343
public function setResults($results = null, bool $stopPropagation = false) {
        $this->result = $results;
        if ($stopPropagation) {
            $this->stopPropagation();
        }
    }
124575
public function addEmailAddress(array $addresses = []): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/user/emails'), Request::METHOD_POST, $addresses);
    }
502101
public function moveCell($fromAddress, $toAddress)
    {
        if ($fromAddress === $this->currentObjectID) {
            $this->currentObjectID = $toAddress;
        }

        $this->deleteQuery->bindValue('id', $toAddress, SQLITE3_TEXT);
        $result = $this->deleteQuery->execute();
        if ($result === false) {
            throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
        }

        $this->updateQuery->bindValue('toid', $toAddress, SQLITE3_TEXT);
        $this->updateQuery->bindValue('fromid', $fromAddress, SQLITE3_TEXT);
        $result = $this->updateQuery->execute();
        if ($result === false) {
            throw new PHPExcel_Exception($this->DBHandle->lastErrorMsg());
        }

        return true;
    }
746903
public function execute(InputInterface $input, OutputInterface $output)
    {
        if (! $this->emailSender) {
            throw new LogicException('No email sender configured (did you set the API key?)');
        }

        if (! $this->emailMapper) {
            throw new LogicException('No email mapper configured');
        }

        $output->writeln('Finding email by ID');

        $emailId = $input->getArgument('id');

        $email = $this->emailMapper->findById($emailId);

        if (!$email or $email->isNew()) {
            throw new OutOfBoundsException('Email not found.');
        }

        $output->writeln('Sending email');

        list($email, $result) = $this->emailSender->send($email);

        if ($email->getStatus() !== EmailEntity::STATUS_SENT) {
            $format = 'Email did NOT send successfully. Returned with status %s.';
            $message = sprintf($format, $result['status']);

            if (isset($result['reject_reason'])) {
                $message .= ' Reason rejected: '.$result['reject_reason'];
            }

            $output->writeln($message);

            return 500;
        }

        $output->writeln('Email sent successfully!');
    }
960168
private function createPhpProcessBuilder(OutputInterface $output, $address)
    {
        $router = realpath(__DIR__ . '/../../Resources/bin/router.php');
        $finder = new PhpExecutableFinder();

        if (false === $binary = $finder->find()) {
            $output->writeln('<error>Unable to find PHP binary to run server</error>');

            return;
        }

        return new ProcessBuilder([$binary, '-S', $address, $router]);
    }
1183988
public function verify($emailAddress)
    {
        $this->response = $this->client->quickemailverification()->verify($emailAddress);

        return $this;
    }
1086584
private function addAddress(
                        &$emailAddresses,
                        &$emailAddress,
                        $encoding,
                        $i)
    {
        if (!$emailAddress['invalid']) {
            if ($emailAddress['address_temp'] || $emailAddress['quote_temp']) {
                $emailAddress['invalid'] = true;
                $emailAddress['invalid_reason'] = "Incomplete address";
                $this->log('error', "Email\\Parse->addAddress - corruption during parsing - leftovers:\n\$i: ${i}\n\$emailAddress['address_temp'] : {$emailAddress['address_temp']}\n\$emailAddress['quote_temp']: {$emailAddress['quote_temp']}\n");
            } elseif ($emailAddress['ip'] && $emailAddress['domain']) {
                // Error - this should never occur
                $emailAddress['invalid'] = true;
                $emailAddress['invalid_reason'] = "Confusion during parsing";
                $this->log('error', "Email\\Parse->addAddress - both an IP address '{$emailAddress['ip']}' and a domain '{$emailAddress['domain']}' found for the email address '{$emailAddress['original_address']}'\n");
            } elseif ($emailAddress['ip'] || ($emailAddress['domain'] && preg_match('/\d+\.\d+\.\d+\.\d+/', $emailAddress['domain']))) {
                // also test if the current domain looks like an IP address

                if ($emailAddress['domain']) {
                    // Likely an IP address if we get here

                    $emailAddress['ip'] = $emailAddress['domain'];
                    $emailAddress['domain'] = null;
                }
                if (!$this->ipValidator) {
                    $this->ipValidator = new Ip();
                }
                try {
                    if (!$this->ipValidator->isValid($emailAddress['ip'])) {
                        $emailAddress['invalid'] = true;
                        $emailAddress['invalid_reason'] = 'IP address invalid: \''.$emailAddress['ip'].'\' does not appear to be a valid IP address';
                    } elseif (preg_match('/192\.168\.\d+\.\d+/', $emailAddress['ip']) ||
                        preg_match('/172\.(1[6-9]|2[0-9]|3[0-2])\.\d+\.\d+/', $emailAddress['ip']) ||
                        preg_match('/10\.\d+\.\d+\.\d+/', $emailAddress['ip'])) {
                        $emailAddress['invalid'] = true;
                        $emailAddress['invalid_reason'] = 'IP address invalid (private): '.$emailAddress['ip'];
                    } elseif (preg_match('/169\.254\.\d+\.\d+/', $emailAddress['ip'])) {
                        $emailAddress['invalid'] = true;
                        $emailAddress['invalid_reason'] = 'IP address invalid (APIPA): '.$emailAddress['ip'];
                    }
                } catch (\Exception $e) {
                    $emailAddress['invalid'] = true;
                    $emailAddress['invalid_reason'] = 'IP address invalid: '.$emailAddress['ip'];
                }
            } elseif ($emailAddress['domain']) {
                // Check for IDNA
                if (max(array_keys(count_chars($emailAddress['domain'], 1))) > 127) {
                    try {
                        $emailAddress['domain'] = $this->getPunycode()->encode($emailAddress['domain']);
                    } catch (\Exception $e) {
                        $emailAddress['invalid'] = true;
                        $emailAddress['invalid_reason'] = "Can't convert domain {$emailAddress['domain']} to punycode";
                    }
                }

                $result = $this->validateDomainName($emailAddress['domain']);
                if (!$result['valid']) {
                    $emailAddress['invalid'] = true;
                    $emailAddress['invalid_reason'] = isset($result['reason']) ? 'Domain invalid: '.$result['reason'] : 'Domain invalid for some unknown reason';
                }
            }
        }

        // Prepare some of the fields needed
        $emailAddress['name_parsed'] = rtrim($emailAddress['name_parsed']);
        $emailAddress['original_address'] = rtrim($emailAddress['original_address']);
        $name = $emailAddress['name_quoted'] ? "\"{$emailAddress['name_parsed']}\"" : $emailAddress['name_parsed'];
        $localPart = $emailAddress['local_part_quoted'] ? "\"{$emailAddress['local_part_parsed']}\"" : $emailAddress['local_part_parsed'];
        $domainPart = $emailAddress['ip'] ? '['.$emailAddress['ip'].']' : $emailAddress['domain'];

        if (!$emailAddress['invalid']) {
            if (mb_strlen($domainPart, $encoding) == 0) {
                $emailAddress['invalid'] = true;
                $emailAddress['invalid_reason'] = 'Email address needs a domain after the \'@\'';
            } elseif (mb_strlen($localPart, $encoding) > 63) {
                $emailAddress['invalid'] = true;
                $emailAddress['invalid_reason'] = 'Email address before the \'@\' can not be greater than 63 characters';
            } elseif ((mb_strlen($localPart, $encoding) + mb_strlen($domainPart, $encoding) + 1) > 254) {
                $emailAddress['invalid'] = true;
                $emailAddress['invalid_reason'] = 'Email addresses can not be greater than 254 characters';
            }
        }

        // Build the email address hash
        $emailAddrDef = ['address' => '',
                        'simple_address' => '',
                        'original_address' => rtrim($emailAddress['original_address']),
                        'name' => $name,
                        'name_parsed' => $emailAddress['name_parsed'],
                        'local_part' => $localPart,
                        'local_part_parsed' => $emailAddress['local_part_parsed'],
                        'domain_part' => $domainPart,
                        'domain' => $emailAddress['domain'],
                        'ip' => $emailAddress['ip'],
                        'invalid' => $emailAddress['invalid'],
                        'invalid_reason' => $emailAddress['invalid_reason']];



        // Build the proper address by hand (has comments stripped out and should have quotes in the proper places)
        if (!$emailAddrDef['invalid']) {
            $emailAddrDef['simple_address'] = "{$emailAddrDef['local_part']}@{$emailAddrDef['domain_part']}";
            $properAddress = $emailAddrDef['name'] ? "{$emailAddrDef['name']} <{$emailAddrDef['local_part']}@{$emailAddrDef['domain_part']}>" : $emailAddrDef['simple_address'];
            $emailAddrDef['address'] = $properAddress;
        }

        $emailAddresses[] = $emailAddrDef;
        return $emailAddrDef['invalid'];
    }