国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

AddEmbeddedImage von PHPMailer gibt mir eine leere E-Mail
P粉702946921
P粉702946921 2024-03-28 13:39:46
0
1
535

Ich habe Probleme beim Abrufen von Inline-Bildern mit PHPMailer. Ohne die folgende Zeile (also wenn ich sie auskommentiere)

$success = $mail->AddEmbeddedImage($ImagePath, $ImageCID, $ImageName, $ImageEncoding, $ImageType, $ImageDisposition);

Es funktioniert gro?artig. Wenn ich es wieder hinzufüge, erhalte ich eine leere E-Mail (habe es mit Outlook und Gmail versucht). Ich habe ?$success=" hinzugefügt, um sicherzustellen, dass es funktioniert, und das tat es auch.

<?php
$BaseURL = "../other/";
require_once($BaseURL . 'PHPMailer-master/src/PHPMailerAutoload.php');
require_once($BaseURL . 'PHPMailer-master/src/PHPMailer.php');
require_once($BaseURL . 'PHPMailer-master/src/SMTP.php');
require_once($BaseURL . 'PHPMailer-master/src/Exception.php');

use PHPMailer\PHPMailer\PHPMailer;

error_reporting(E_ALL);
ini_set('display_errors', 1);
// Test data begin
$encoding =""; // Also tried "base64"
$type=""; // Also tried "application/octet-stream" and "image/jpeg"
$disposition = "inline";
$ImageArray = array("../images/Logo.jpg|Logo|Logo.jpg|" . $encoding . "|" . $type . "|" . $disposition,
                    "../images/XX1.jpg|XX1|XX1.jpg|" . $encoding . "|" . $type . "|" . $disposition);
$Body = '<html><body style="font-family:Verdana, Verdana, Geneva, sans-serif; font-size:12px; color:#666666;">';
$Body .= 'This is a test from SendEmail and contains default text in the message body.';
$Body .= 'And an image... <img src="cid:Logo">';
$Body .= '<br><br></body></html>';
$SendParams = array("SendTo"=>array("xx@gmail.com, XX", "xx@example.com, XX/example"), 
                    "Body"=>$Body,
                    "Subject"=>"This is the default Subject",
                    "Images"=>$ImageArray
                    );
SendEmail($SendParams);
// End Test data and calls

function SendEmail($params) {
    $mail = new PHPMailer;
    $mail->IsHTML(true);
    $mail->isSMTP();
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'tls';
    $mail->Host = "smtp.gmail.com";
    $mail->Mailer = "smtp";
    $mail->Port = 587; //use port 465 when using SMPTSecure = 'ssl'
    $mail->Username = "exampele@gmail.com";
    $mail->Password = "xxxxxxxxxxxxxxxxxxx";    // $mail->SMTPDebug = SMTP::DEBUG_SERVER;
    if (!isset($params)) {
        die("Kaput!");
    }
    $SendTo = isset($params["SendTo"]) ?  $params["SendTo"] : array("xx@example.com, XX/example");
    $Body = isset($params["Body"]) ?  $params["Body"] : "No Message Body - may be a Test!";
    $Subject = isset($params["Subject"]) ?  $params["Subject"] : "No Message Subject - may be a Test!";
    foreach($SendTo as $recipient) {
        $recipient_array = explode(",", $recipient);
        $SendEmail = $recipient_array[0];
        $SendName = $recipient_array[1];
        $mail->AddAddress($SendEmail, $SendName);
    }
    if (isset($params["Images"])) {
        foreach($params["Images"] as $ImageData) {
            $ImageData_array = explode("|", $ImageData);
            $ImagePath = $ImageData_array[0];
            $ImageCID = $ImageData_array[1];
            $ImageName = $ImageData_array[2];
            $ImageEncoding = $ImageData_array[3];
            $ImageType = $ImageData_array[4];
            $ImageDisposition = $ImageData_array[5];
            // Below is the line causing the problem
            $success = $mail->AddEmbeddedImage($ImagePath, $ImageCID, $ImageName, $ImageEncoding, $ImageType, $ImageDisposition);
            // The below prints expected values for the variables ("Failed!" does not print)
            if ($success)
                echo "<br><br>Image: " . $ImagePath . ", " . $ImageCID . ", " . $ImageName . ", " . $ImageEncoding . ", " . $ImageType . ", " . $ImageDisposition;
            else
                echo "Failed!";
        }
    }
    $mail->Body = $Body;
    $mail->Subject = $Subject;
    $mail->SetFrom('admin@example.com', 'example Admin');
    $mail->addReplyTo('admin@example.com');
    if (!$mail->send()) {
        echo "Mailer Error: " . $mail->ErrorInfo;
     } else {
        echo "Message sent!";
    }
}
?>

Das ist die Bildschirmausgabe:

Bilder: ../images/Logo.jpg,Logo,Logo.jpg,,,inline

Bilder: ../podbanks/images/XX.jpg, XX, XX.jpg,,, inline


Mail: Object(PHPMailerPHPMailerPHPMailer)#1 (71) { ["Priority"]=> NULL ["CharSet"]=> string(10) "iso-8859-1" ["ContentType"]=> "text/html" ["Encoding"]=> string(4) "8bit" ["ErrorInfo"]=> "" ["Absender"]=> String(18) "admin@example.com" ["Absendername"]=> ?Example Admin“[?Sender“]=> string(18)“admin@example.com“ ["Subject"]=> string(27) "Dies ist das Standardthema" ["Body"]=> string(215) ?Dies ist ein Test von SendEmail, der Standardtext enth?lt im Nachrichtentext.Es gibt auch ein Bild..." ["AltBody"]=> string(0) "" ["Ical"]=> string(0) "" ["MIMEBody":protected]=> ["MIMEHeader":protected]=> string(0) "" ["mailHeader":protected]=> string(0) "" ["WordWrap"]=> int(0) ["Mailer"]=> ["Sendmail"]=> string(18) "/usr/sbin/sendmail" ["UseSendmailOptions"]=> bool(true) ["ConfirmReadingTo"]=> "" ["Hostname"]=> string(0) "" ["MessageID"]=> ["MessageDate"]=> String(0) "" ["Host"]=> ["Port"]=> int(587) ["Helo"]=> string(0) "" ["SMTPSecure"]=> "tls" ["SMTPAutoTLS"]=> bool(true) ["SMTPAuth"]=> ["SMTPOptions"]=> array(0) { } ["Benutzername"]=> ?examplemail@gmail.com“ [?password“]=> string(16) ?shotlzacfvdubehm“ ["AuthType"]=> String(0) "" ["oauth":protected]=> int(300) ["SMTPDebug"]=> int(0) ["Debugoutput"]=> ["SMTPKeepAlive"]=> bool(false) ["SingleTo"]=> ["SingleToArray":protected]=> array(0) { } ["do_verp"]=> ["AllowEmpty"]=> bool(false) ["DKIM_selector"]=> ["DKIM_identity"]=> string(0) "" ["DKIM_passphrase"]=> ["DKIM_domain"]=> string(0) "" ["DKIM_private"]=> ["DKIM_private_string"]=> string(0) "" ["action_function"]=> "" ["XMailer"]=> String(0) "" ["smtp":protected]=> ["to":protected]=> array(2) { [0]=> string(19) "aa@gmail.com" 1=> string(10) "AA" } 1=> array(2) { [0]=> String(15) "aa@example.com" 1=> String(13) "A/example" } } ["cc":protected]=> array(0) { } ["bcc":protected]=> ["ReplyTo":protected]=> array(1) { ["admin@example.com"]=> [0]=> String(18) "admin@example.com" 1=> ["all_recipients":protected]=> array(2) { ["aa@gmail.com"]=> bool(true) ["ag@example.com"]=> ["RecipientsQueue":protected]=> array(0) { } ["ReplyToQueue":protected]=> array(0) { } ["attachment":protected]=> Array(2) { [0]=> Array(8) { [0]=> "../images/clients/Logo.jpg" 1=> string(13) "Logo.jpg" 2=> String(13) ?Logo.jpg“ [3]=> String(0) ?“ [4]=> [5]=> bool(false) [6]=> string(6) "inline" [7]=>1=> array(8) { [0]=> string(35) "../images/XX.jpg" 1=> "XX.jpg" 2=> string(16) "XX.jpg" [3]=> string(0) "" [4]=> ?image/jpeg“ [5]=> bool(false) [6]=> string(3) "XX" } } ["CustomHeader":protected]=> array(0) { } ["lastMessageID":protected]=> string(0) "" ["message_type":protected]=> string(0) "" ["boundary":protected]=> array(0) { } ["Sprache": protected]=> array(0) { } ["error_count":protected]=> int(0) ["sign_cert_file":protected]=> String(0) ?“ [?sign_key_file“:protected]=> ["sign_extracerts_file": protected] => string(0) "" ["sign_key_pass": protected] = > string(0) "" ["Exception": protected] = > bool(false) ["uniqueid":protected]=> string(0) "" } Nachricht wurde gesendet!

Ich kann auch keine umfassende Dokumentation finden – nicht einmal auf GitHub: 3731. Das, was mir am n?chsten kam, war dieses. Aber ich verstehe immer noch nicht, was genau der dritte Parameter macht. M?chte ich den Namen überschreiben? Warum? Welche Kodierung soll ich verwenden (ich habe Base64 ausprobiert und beide leer gelassen)? Welche M?glichkeiten gibt es neben der ?Inline“-Entsorgung? Warte...

P粉702946921
P粉702946921

Antworte allen(1)
P粉164942791

首先,您似乎正在使用舊版本的 PHPMailer,因?yàn)槟昧艘粋€(gè)多年來(lái)一直不屬于庫(kù)的文件(自動(dòng)加載器),因此請(qǐng)更新。

您的代碼看起來(lái)像是基于一個(gè)非常古老的示例。您不應(yīng)該自己設(shè)置 MailerisSMTP() 會(huì)為您完成此操作。

如果磁盤(pán)上的文件具有您不想向收件人公開(kāi)的不同名稱(chēng),您可能需要覆蓋該名稱(chēng),例如您本地可能有 logo-123456.png,并希望將其附加為 logo.png。

編碼幾乎總是需要為 base64,因?yàn)閳D像往往是二進(jìn)制的,因此電子郵件不安全,因此請(qǐng)將其保留為默認(rèn)值。

MIME 類(lèi)型應(yīng)該與文件擴(kuò)展名匹配,因此您也應(yīng)該能夠忽略這一點(diǎn)(PHPMailer 將為您設(shè)置它),除非您有非常具體的原因來(lái)設(shè)置不匹配的 MIME 類(lèi)型 em> 匹配您的內(nèi)容。

$disposition 設(shè)置來(lái)自 RFC2183。對(duì)于嵌入圖像使用除內(nèi)聯(lián)之外的任何內(nèi)容都沒(méi)有多大意義,因此您也應(yīng)該將其保留為默認(rèn)值。該選項(xiàng)存在是因?yàn)?RFC 規(guī)定它應(yīng)該存在。

所有這些的結(jié)果是,您實(shí)際需要提供的只是文件的路徑和 cid。

如果您顯示 SMTP 記錄(設(shè)置 SMTPDebug = 2),可能會(huì)有所幫助,因?yàn)檫@將準(zhǔn)確顯示您的郵件中發(fā)生的情況。

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage