public static function fromArray(array $array) { $message = new self($array['subject']); if (null !== $array['sender']) { $message->setSender($array['sender']); } if (null !== $array['from']) { $message->setFrom($array['from']); } if (null !== $array['to']) { $message->setTo($array['to']); } if (null !== $array['replyTo']) { $message->setReplyTo($array['replyTo']); } if (null !== $array['cc']) { $message->setCc($array['cc']); } if (null !== $array['bcc']) { $message->setBcc($array['bcc']); } if (null !== $array['text']) { $message->setBodyWithAlternative($array['text'], $array['html']); } foreach ($array['customHeaders'] as $label => $valueList) { foreach ($valueList as $value) { $message->getHeaders()->addTextHeader($label, $value); } } return $message; }
/** * @param array $recipient Recipient e-mail address * @param string $subject E-mail subject * @param string $body Message body * @param bool $html - HTML mail or plain text * @param array $replyto Reply to email address * @param array $cc CC e-mail address * @param array $bcc BCC e-mail address * @param string $attachment Attachment file name * @param array $cert - pem certificate * @param array $from - array( from, fromname ) * @internal param array $replytoname Reply to name * @return boolean True on success */ public static function SpSendMail($recipient, $subject, $body, $html = false, $replyto = null, $cc = null, $bcc = null, $attachment = null, $cert = null, $from = null) { $from = is_array($from) ? $from : array(Sobi::Cfg('mail.from'), Sobi::Cfg('mail.fromname')); $mail = new self(); $mail->setSender($from); $mail->setSubject($subject); $mail->setBody($body); if ($html) { $mail->IsHTML(true); } if ($cert) { $mail->Sign($cert['certificate'], $cert['key'], $cert['password']); } $mail->addRecipient($recipient); $mail->addCC($cc); $mail->addBCC($bcc); $mail->addAttachment($attachment); $mail->addReplyTo($replyto); return $mail->Send(); }
public static function sendMailS($sender, $receiver, $subject, $body, $html = false, $resendCheck = false) { $mail = new self(); $mail->setSender($sender); $mail->setReceiver($receiver); $mail->setSubject($subject); $mail->setBody($body); $mail->setResendCheck($resendCheck); return false === $html ? $mail->sendAsText() : $mail->sendAsHTML(); }