PhpMailer Fatal Error bei Ausführung

FranzvonAssisi

Admiral
Registriert
Dez. 2013
Beiträge
7.402
Hey,

ich habe ein Problem mit PHPMailer, habe sonst immer andere Libs verwendet.


PHP:
$mail = new PHPMailer;

$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.strato.de';                 // Specify SMTP servers
$mail->SMTPAuth = true;                          // Enable SMTP auth
$mail->Username = '*****@***.de';        // SMTP usern
$mail->Password = '********;                 // SMTP passw
$mail->SMTPSecure = 'tls';                       // Enable TLS 
$mail->Port = 465;                                  // TCP port

$mail->setFrom('no-reply@***.de', 'no-reply@***.de');
$mail->addAddress('***.***@***.de');     // Add a recipient

$mail->isHTML(true);                               // Set email format to HTML

$mail->Subject = 'Neue Anfrage von '.$name;
$mail->Body    = $mail;
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients Blabla';

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}


Die Fehlermeldung:
Code:
Warning: preg_match() expects parameter 2 to be string, object given in /mnt/****/a3/95/53351895/htdocs/path/to/Phpmailer/PHPMail/class.phpmailer.php on line 2843

Warning: preg_match() expects parameter 2 to be string, object given in /mnt/****/a3/95/53351895/htdocs/path/to/Phpmailer/PHPMail/class.phpmailer.php on line 3947

Catchable fatal error: Object of class PHPMailer could not be converted to string in /mnt/****/a3/95/53351895/htdocs/path/to/Phpmailer/PHPMail/class.phpmailer.php on line 3345


In Zeile 3345 befindet sich folgende Funktion
PHP:
/**
     * Ensure consistent line endings in a string.
     * Changes every end of line from CRLF, CR or LF to $this->LE.
     * @access public
     * @param string $str String to fixEOL
     * @return string
     */
    public function fixEOL($str)
    {
        // Normalise to \n
        $nstr = str_replace(array("\r\n", "\r"), "\n", $str);    /// ZEILE 3345
        // Now convert LE as needed
        if ($this->LE !== "\n") {
            $nstr = str_replace("\n", $this->LE, $nstr);
        }
        return $nstr;
    }

Irgendjemand eine Idee? Wahrscheinlich liegt der Fehler bei meiner Anwendung, aber ich finds gerade nicht...

Lg, Franz


Edit: Ach ich bin zu blöd... Hab meinen HTML Mailtext in einer Variable namens mail gespeichert und dann den PHPMailer drübergeschrieben :D -> gelöst
 
Zuletzt bearbeitet:
In Zeile 17 übergibst du das $mail-Objekt nochmal als Body. Da musst du einfach den Inhalt der Email als String übergeben.

EDIT: Sorry, hab dein EDIT übersehen :D
 
Zurück
Oben