jensgebken
Goto Top

Prob mit phpmailer

hallo gemeinschaft

habe ein prob mit einem plugin von wordpress welches den phpmailer verwendet

ich möchte, dass bei jeder mail auch eine pdf datei mit versendet wird - ich habe bereits den pfad hinterlegt, in dem die datei liegt - leider schickt er diese nicht mit

das ist der teil des phpmailers

<?
public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') {
try {
if ( !@is_file($path) ) {
throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE);
}
$filename = basename($path);
if ( $name == '' ) {
$name = $filename;
}

$this->attachment = array(
0 => $path,
1 => $filename,
2 => $name,
3 => $encoding,
4 => $type,
5 => false, isStringAttachment
6 => 'attachment',
7 => 0
);

} catch (phpmailerException $e) {
$this->SetError($e->getMessage());
if ($this->exceptions) {
throw $e;
}
echo $e->getMessage()."\n";
if ( $e->getCode() == self::STOP_CRITICAL ) {
return false;
}
}
return true;
}

/**
      • Return the current array of attachments
      • @return array
*/
public function GetAttachments() {
return $this->attachment;
}
?>

hier der teil woraus die mail generiert wird
<?
$fromEmail = $settings->SMTP_EMAIL;
$fromName = $settings->SMTP_NAME;

if ($settings->email_mode == '4') {
$headers = 'From: '.$fromName.' <'.$settings->SMTP_EMAIL.'>' . "\r\n";
$headers .= 'Content-Type: text/html; charset="UTF-8" \r\n';
$stat = wp_mail($email, $sub, $msg, $headers);
return ($stat) ? 'sent' : 'Error with wp mail';
} else {
if (!class_exists('PHPMailer')) require_once dirname( __FILE__ ) . '/class.phpmailer.php';

try {
$mail = new PHPMailer(true);

if ($settings->email_mode == '1') {
$mail->IsMail();
} else {
$mail->IsSMTP();
}
$mail->SMTPAuth = true;

if ($settings->emailSSL != "false") $mail->SMTPSecure = $settings->emailSSL;

$mail->Port = $settings->SMTP_PORT;
$mail->Host = $settings->SMTP_HOST;
$mail->Username = $settings->SMTP_EMAIL;
$mail->Password = $settings->SMTP_PASS;


$mail->AddReplyTo($fromEmail, $fromName);
$mail->From = $fromEmail;
$mail->FromName = $fromName;

$mail->AddAddress($email);
$mail->Subject = $sub;

$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->AddAttachment("/www/htdocs/w00fcb5e/meinedomain.de/test.pdf");
attachment geändert
$mail->MsgHTML($msg);
$mail->IsHTML(true);
// $mail->CharSet = 'UTF-8';

if (!$mail->Send()){
return $mail->ErrorInfo;
}

return "sent";
} catch (phpmailerException $e) {
return "Exception Error: ".$e->errorMessage() ;
}
}

}
?>

Content-Key: 310333

Url: https://administrator.de/contentid/310333

Ausgedruckt am: 28.03.2024 um 18:03 Uhr

Mitglied: andrix
Lösung andrix 20.07.2016 um 16:00:38 Uhr
Goto Top
Hallo,

Bitte benutze die Code Blöcke damit das ganze besser lesbar wird.

sieht auf dem ersten Blick richtig aus. Ich würde deshalb auf einen Falschen Pfad oder Rechte Problem Tippen. Änder bitte mal
$mail->AddAttachment("/www/htdocs/w00fcb5e/meinedomain.de/test.pdf");  
zu
if($mail->AddAttachment("/www/htdocs/w00fcb5e/meinedomain.de/test.pdf")) echo "kein Fehler beim Datei anhang";  
else echo "Fehler beim Datei anhang";  

Grüße
Mitglied: jensgebken
jensgebken 21.07.2016 um 08:51:05 Uhr
Goto Top
hi andrix,

hat geklappt

lieben dank lag am pfad - es fehler ein "/" face-smile