Home > PHP > Mail versenden mit Swift_Mailer

Mail versenden mit Swift_Mailer

function sendHtmlMail($from, $to, $subject, $body, $attachments = array()) {
    require_once 'lib/swift_required.php';
 
    $message = Swift_Message::newInstance()
      ->setSubject($subject)
      ->setFrom($from)
      ->setTo($to)
      ->setBody($body, 'text/html');
 
    $transport = Swift_SmtpTransport::newInstance('host', 25)
      ->setUsername('username')
      ->setPassword('password');
 
    $mailer = Swift_Mailer::newInstance($transport);
    return $mailer->send($message);
}
 
var_dump(sendHtmlMail("fromMailAddress", "toMailAddress", "subject", "body"));

No related posts.

Author: Categories: PHP Tags:
  1. Bisher keine Kommentare
  1. Bisher keine Trackbacks