Exemplo n.º 1
0
 public function sendInvoiceEmail(Document $invoice, Parameters $data, $documentFile)
 {
     $companyFiles = array();
     $params = new Parameters();
     if (isset($data->smtp) && $data->smtp > 0) {
         $smtp = $this->getOneObjectByField(SmtpOptions::getClass(), 'id', $data->smtp);
         $params->transport = $smtp->getTransport();
     }
     $params->from = $data->from;
     $params->to = $data->to;
     $params->header = $data->header;
     $params->content = $data->content;
     $params->documentFile = $documentFile;
     if (isset($data->companyFiles)) {
         foreach ($data->companyFiles as $id) {
             $companyFile = $this->getOneObjectByField(Company\File::getClass(), 'id', $id);
             $companyFiles[] = $companyFile;
         }
     }
     $params->companyFiles = $companyFiles;
     $this->mailService->sendInvoiceWithParams($invoice, $params);
 }
Exemplo n.º 2
0
 public function saveSmtpWithParams(SmtpOptions $smtpOptions, array $data)
 {
     if (isset($data['name'])) {
         $smtpOptions->setName($data['name']);
     }
     if (isset($data['host'])) {
         $smtpOptions->setHost($data['host']);
     }
     if (isset($data['username'])) {
         $smtpOptions->setUsername($data['username']);
     }
     if (isset($data['password'])) {
         $smtpOptions->setPassword($data['password']);
     }
     if (isset($data['connectionClass'])) {
         $smtpOptions->setConnectionClass($data['connectionClass']);
     }
     if (isset($data['ssl'])) {
         $smtpOptions->setSsl($data['ssl']);
     }
     if (isset($data['port'])) {
         $smtpOptions->setPort($data['port']);
     }
     if (isset($data['default'])) {
         $smtpOptions->setDefault(1);
     } else {
         $smtpOptions->setDefault(0);
     }
     return $this->saveSmtp($smtpOptions);
 }