Send an email containing the file to the current client by Email.

@param $operation

@return bool
977074
private function operationEmail($operation)
    {
        if ($this->test) {
            $to = !empty($operation->test) ? $operation->test : (!empty($operation->to) ? $operation->to : '');
        } else {
            $to = !empty($operation->to) ? $operation->to : '';
        }
        if (!$to) {
            $this->setLogs('Email to address is invalid. No email will be sent.', 'error');

            return false;
        }
        $from  = (isset($operation->from) && !empty(trim($operation->from)))
            ? $operation->from : $this->getIntegrationSetting('email_from');
        $email = new Email();
        $email->setSessionId('new_'.hash('sha1', uniqid(mt_rand())));
        $email->setReplyToAddress($from);
        $email->setFromAddress($from);
        $subject = (isset($operation->subject) && !empty(trim($operation->subject)))
            ? $operation->subject : $this->file->getName();
        $email->setSubject($subject);
        if ($this->file->getCount()) {
            $body = (isset($operation->successMessage) && !empty(trim($operation->successMessage)))
                ? $operation->successMessage : $this->getIntegrationSetting('success_message');
        } else {
            $body = (isset($operation->emptyMessage) && !empty(trim($operation->emptyMessage)))
                ? $operation->emptyMessage : $this->getIntegrationSetting('empty_message');
        }
        $body .= PHP_EOL.PHP_EOL.((isset($operation->footer) && !empty(trim($operation->footer)))
                ? $operation->footer : $this->getIntegrationSetting('footer'));
        $email->setContent($body);
        $email->setCustomHtml(htmlentities($body));

        /** @var MailHelper $mailer */
        $mailer = $this->mailHelper->getMailer();
        $mailer->setLead(null, true);
        $mailer->setTokens([]);
        $to = (!empty($to)) ? array_fill_keys(array_map('trim', explode(',', $to)), null) : [];
        $mailer->setTo($to);
        $mailer->setFrom($from);
        $mailer->setEmail($email);
        $mailer->attachFile($this->file->getLocation(), $this->file->getName());

        $this->setLogs($to, 'emailTo');
        $this->setLogs($from, 'emailFrom');
        $this->setLogs($subject, 'emailSubject');
        $this->setLogs($body, 'emailbody');

        // $mailer->setBody($email);
        // $mailer->setEmail($to, false, $emailSettings[$emailId]['slots'], $assetAttachments, (!$saveStat));
        // $mailer->setCc($cc);
        // $mailer->setBcc($bcc);

        // [ENG-683] start/stop transport as suggested by http://www.prowebdev.us/2013/06/swiftmailersymfony2-expected-response.html and
        // https://github.com/php-pm/php-pm-httpkernel/issues/62#issuecomment-410667217

        $repeatSend = true;
        $sendTry    = 1;
        while ($repeatSend || $sendTry < 4) {
            if (!$mailer->getTransport()->isStarted()) {
                $mailer->getTransport()->start();
            }
            $mailResult = $mailer->send(false, false);
            if ($errors = $mailer->getErrors()) {
                $this->setLogs($errors, 'sendError');
            } else {
                $repeatSend = false;
            }
            ++$sendTry;
            $mailer->getTransport()->stop();
        }

        return $mailResult;
    }
284071
public function checkPermission($operation, $resource = null)
    {
        $path = $this->getFullPathName();
        if (!empty($resource)) {
            $path = (!empty($path)) ? $path . '/' . $resource : $resource;
        }

        $requestType = ($this->request) ? $this->request->getRequestorType() : ServiceRequestorTypes::API;

        Session::checkServicePermission($operation, $this->getServiceName(), $path, $requestType);

        return true;
    }
887827
protected function send($s)
    {
        if (!$this->socket) {
            $this->createSocket();
        }

        if (!$this->socket) {
            return false;
        }

        $written = 0;
        while ($s != '') {
            $written = $this->write($s);
            if ($written === false) {
                throw new \Plop\Exception('Connection lost');
            }
            $s = (string) substr($s, $written);
        }
        return true;
    }
45373
public function processContent(Operation $operation, $data)
    {
        try {
            if(is_array($data)) {
                $message = $this->contentService->getMessageByOperation($operation);
                $message->setMessage($data['message']);
            } else {
                $message = $data;            
            }
        } catch (\Exception $e){
            // message has not been created yet, so do it from the form data.
            $message = $data;
        }
        return $message;
    }
198629
public function whyCantDo($operation)
    {
        if (!is_string($operation)) {
            return 'Invalid $operation';
        }
        if (!isset($this->operationErrors[$operation])) {
            switch ($operation) {
                case static::OPERATION_MOVE:
                    $error = $this->whyCantMove();
                    break;
                case static::OPERATION_ALIAS:
                    $error = $this->whyCantAlias();
                    break;
                case static::OPERATION_COPY:
                    $error = $this->whyCantCopy();
                    break;
                case static::OPERATION_COPYALL:
                    $error = $this->whyCantDo(static::OPERATION_COPY);
                    if ($error === '') {
                        $error = $this->whyCantCopyAll();
                    }
                    break;
                case static::OPERATION_COPYVERSION:
                    $error = $this->whyCantCopyVersion();
                    break;
                default:
                    return 'Invalid $operation';
            }
            $this->operationErrors[$operation] = $error;
        }

        return $this->operationErrors[$operation];
    }
421067
private function operationSftp($operation)
    {
        $config = $this->operationFtpConfig($operation);

        $adapter    = new SftpAdapter($config);
        $filesystem = new Filesystem($adapter);

        $written = false;
        if ($stream = fopen($this->file->getLocation(), 'r+')) {
            $this->setLogs($this->file->getLocation(), 'sftpUploading');
            $written = $filesystem->writeStream($this->file->getName(), $stream);
            if (is_resource($stream)) {
                fclose($stream);
            }
            $this->setLogs($written, 'sftpConfirmed');
            if (!$written) {
                $this->setLogs('Could not confirm file upload via SFTP', 'error');
            } else {
                $this->setLogs($filesystem->has($this->file->getName()), 'sftpConfirmed2');
            }
        } else {
            $this->setLogs('Unable to open file for upload via SFTP.', 'error');
        }

        return $written;
    }
636480
public function client_send($data)
    {
        if ($this->do_debug >= 1) {
            $this->edebug("CLIENT -> SERVER: $data");
        }
        return fwrite($this->smtp_conn, $data);
    }
726853
public function send()
    {
        $transport = $this->getConnection()->getTransportObject();

        // Refactor: Not full toArray needed in exec?
        return $transport->exec($this, $this->getConnection()->toArray());
    }
73471
public function send()
    {
        // if no recipients found, skipping sending
        if (count($this->getRecipient()) < 1) {
            return false;
        }

        $myConfig = Registry::getConfig();
        $this->setCharSet();

        if ($this->_getUseInlineImages()) {
            $this->_includeImages(
                $myConfig->getImageUrl(),
                $myConfig->getImageUrl(false, false),
                $myConfig->getPictureUrl(null, false),
                $myConfig->getImageDir(),
                $myConfig->getPictureDir(false)
            );
        }

        $this->_makeOutputProcessing();

        // try to send mail via SMTP
        if ($this->getMailer() == 'smtp') {
            $ret = $this->_sendMail();

            // if sending failed, try to send via mail()
            if (!$ret) {
                // failed sending via SMTP, sending notification to shop owner
                $this->_sendMailErrorMsg();

                // trying to send using standard mailer
                $this->setMailer('mail');
                $ret = $this->_sendMail();
            }
        } else {
            // sending mail via mail()
            $this->setMailer('mail');
            $ret = $this->_sendMail();
        }

        if (!$ret) {
            // failed sending, giving up, trying to send notification to shop owner
            $this->_sendMailErrorMsg();
        }

        return $ret;
    }
736168
public function send()
    {
        $contactFormBridge = $this->getContainer()->get(ContactFormBridgeInterface::class);

        $form = $contactFormBridge->getContactForm();
        $form->handleRequest($this->getMappedContactFormRequest());

        if ($form->isValid()) {
            $this->sendContactMail(
                $form->email->getValue(),
                $form->subject->getValue(),
                $contactFormBridge->getContactFormMessage($form)
            );
        } else {
            foreach ($form->getErrors() as $error) {
                Registry::getUtilsView()->addErrorToDisplay($error);
            }

            return false;
        }
    }
1261311
public function send(ClientCommand $command)
	{
		$request = $this->client->createRequest(
			$command->method(),
			$this->client->getBaseUrl() . $command->uri($this->cryptographyEngine),
			$this->headers($command->apiVersion(), $command->format(), $command->headers()),
			$command->body($this->cryptographyEngine),
			$this->config->getHttpClientConfig()
		);

		try {
			$response = $request->send();
		} catch (ClientErrorResponseException $exception) {
			$response = $exception->getResponse();
		} catch (ServerErrorResponseException $exception) {
			$response = $exception->getResponse();
		}

		return $command->response($response, $this->cryptographyEngine);
	}
1064668
public function send($outbox=null)
    {

        if($outbox instanceof Writer){
            self::$outbox = $outbox;
        } elseif(!self::$outbox){
            self::$outbox = new Writer();
        }

        if($this->onBeforeSend($this) !== false){
            
            self::$outbox->addEmailToOutbox($this);

            //return if sent
            return self::$outbox->send();
        }

    }
855871
public function send_file($file) {
        $this->googleoauth->setHeader("Content-Length: ". $file->get_filesize());
        $this->googleoauth->setHeader("Content-Type: ". $file->get_mimetype());
        $this->googleoauth->setHeader("Slug: ". $file->get_filename());

        $this->googleoauth->post(self::UPLOAD_LOCATION, $file->get_content());

        if ($this->googleoauth->info['http_code'] === 201) {
            return true;
        } else {
            return false;
        }
    }
15857
protected function _send()
	{
		$message = $this->build_message();
		$return_path = ($this->config['return_path'] !== false) ? $this->config['return_path'] : $this->config['from']['email'];
		if ( ! @mail(static::format_addresses($this->to), $this->subject, $message['body'], $message['header'], '-oi -f '.$return_path))
		{
			throw new \EmailSendingFailedException('Failed sending email');
		}
		return true;
	}
1214349
function send($file,$mime=NULL,$kbps=0,$force=TRUE) {
		if (!is_file($file))
			return FALSE;
		$size=filesize($file);
		if (PHP_SAPI!='cli') {
			header('Content-Type: '.($mime?:$this->mime($file)));
			if ($force)
				header('Content-Disposition: attachment; '.
					'filename='.var_export(basename($file),TRUE));
			header('Accept-Ranges: bytes');
			header('Content-Length: '.$size);
			header('X-Powered-By: '.Base::instance()->get('PACKAGE'));
		}
		$ctr=0;
		$handle=fopen($file,'rb');
		$start=microtime(TRUE);
		while (!feof($handle) &&
			($info=stream_get_meta_data($handle)) &&
			!$info['timed_out'] && !connection_aborted()) {
			if ($kbps) {
				// Throttle output
				$ctr++;
				if ($ctr/$kbps>$elapsed=microtime(TRUE)-$start)
					usleep(1e6*($ctr/$kbps-$elapsed));
			}
			// Send 1KiB and reset timer
			echo fread($handle,1024);
		}
		fclose($handle);
		return $size;
	}
46413
protected function hasHooks($operation)
    {
        return $this->enableHooks &&
            is_subclass_of($this->class, Hookable::class) &&
            (method_exists($this->class, "before$operation") || method_exists($this->class, "after$operation"));
    }
419963
public function send($headers)
    {
        $this->debug->groupCollapsed(__METHOD__);
        // $this->debug->log('headers', $headers);
        $return = false;
        self::normalizeHeaders($headers, $this->cfg['email']['from']);
        if (!empty($headers['Attachments'])) {
            $headers['MIME-Version'] = '1.0';
            if (!empty($headers['Body'])) {
                array_unshift($headers['Attachments'], array('body'=>$headers['Body']));
                if (!empty($headers['Content-Type'])) {
                    $headers['Attachments'][0]['content_type'] = $headers['Content-Type'];
                }
            }
            list($headers['Content-Type'], $headers['Body']) = $this->buildBody($headers['Attachments']);
            unset($headers['Attachments']);
        }
        $this->debugHeaders($headers);
        $headersAddStr = self::buildAdditionalHeadersString($headers);
        $params = array($headers['To'], $headers['Subject'], $headers['Body'], $headersAddStr);
        if (!ini_get('safe_mode')) {
            $params[] = self::buildAdditionalParamsString($headers);
        }
        if ($headers['To']) {
            if ($this->cfg['debugMode']) {
                $this->debug->warn('debugMode: email not sent');
                // don't sent email when debug=true
                $return = true;
                $this->debugResult = $params;
            } else {
                $return = call_user_func_array('mail', $params);
            }
        }
        $this->debug->log('Email was '.(($return)?'':'NOT').' successful');
        $this->debug->groupEnd();
        return $return;
    }