<?php
/**
 * E-Mail über Variomedia SMTP Server (smtp.variomedia.de) senden
 *
 * Benutzt PHPMailer (https://github.com/Synchro/PHPMailer)
 *
 * Benötigt PHP Version 5+
 */

require 'PHPMailerAutoload.php';

class VRMDMailer extends PHPMailer
{

    /**
     * Konstruktor
     *
     * @param string    $username   SMTP Benutzername
     * @param string    $password   SMTP Passwort
     * @param boolean   $exceptions Exceptions aktivieren, default: false
     */   
    public function __construct($username, $password, $exceptions = false) {
        parent::__construct($exceptions);
        $this->IsSMTP();
        $this->Host = 'smtp.variomedia.de';
        $this->SMTPAuth = true;
        $this->SMTPSecure = 'tls';
        $this->Username = $username;
        $this->Password = $password;
        $this->WordWrap = 72;
    }

    /**
     * Destruktor
     */
    public function __destruct() {
        parent::__destruct();
    }

    /**
     * Sende E-Mail
     *
     * @param string    $to         Empfängeradresse
     * @param string    $subject    Betreff
     * @param string    $message    Nachricht
     * @param string    $from       Absenderadresse
     * @param string    $fromname   Absendername, default: leer
     *
     * @return boolean success
     */
    public function mail($to, $subject, $message, $from, $fromname='') {
        $this->From = $from;
        $this->FromName = $fromname;
        $this->AddAddress($to);
        $this->Subject = $subject;
        $this->Body = $message;
        $ret = $this->Send();
        $this->clearAddresses();
        $this->clearAttachments();
        return $ret;
    }

}
?>