*/ function send( \alveolata\email\struct_credentials $credentials, \alveolata\email\struct_data $data ) : void { // Create the Transport $transport = new \Swift_SmtpTransport( $credentials->host, $credentials->port, [ \alveolata\email\enum_negotiation_type::none => null, \alveolata\email\enum_negotiation_type::opportunistic => 'tls', \alveolata\email\enum_negotiation_type::forced => 'ssl', ][$credentials->negotiation_type] ); $transport->setUsername($credentials->username); $transport->setPassword($credentials->password); // Create the Mailer using your created Transport $mailer = new \Swift_Mailer($transport); // Create a message $message = new \Swift_Message(); if (! empty($data->from)) { $message->setFrom([$data->from]); } $message->setTo($data->to); if (! empty($data->cc)) { $message->setCc($data->cc); } if (! empty($data->bcc)) { $message->setBcc($data->bcc); } $message->setSubject($data->subject); if (! empty($data->body_html)) { $message->setBody($data->body_html, 'text/html'); if (! empty($data->body_plain)) { $message->addPart($data->body_plain, 'text/plain'); } } else { $message->setBody($data->body_plain, 'text/plain'); } foreach ($data->attachments as $attachment) { $attachment_ = \Swift_Attachment::fromPath($attachment['path'], $attachment['mime']); $attachment_->setFilename($attachment['name']); $message->attach($attachment_); } // Send the message $result = $mailer->send($message); }