Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ical not shown with AddEmbeddedImage or AddAttachment #2315

Closed
Borsti26 opened this issue Apr 17, 2021 · 9 comments
Closed

Ical not shown with AddEmbeddedImage or AddAttachment #2315

Borsti26 opened this issue Apr 17, 2021 · 9 comments

Comments

@Borsti26
Copy link

Borsti26 commented Apr 17, 2021

Problem description

If i want to send a mail with ical event and an Embedded Image or Attachment the ical is not shown.
Without Embedded Image or Attachment the ical is vissible.
I testet Outlook and Gmail.

Code to reproduce

$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPOptions = array(
    'ssl' => array(
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    )
);
$mail->Host = $ma['smtp'];
$mail->SMTPAuth = true;
$mail->Username = $ma['user'];
$mail->Password = $ma['pass'];
$mail->SMTPSecure = 'tls';
$mail->Port = $ma['smtp_port'];
$mail->CharSet = 'UTF-8';
$mail->setFrom($ma['mail'], $ma['name']);
$mail->addAddress("[email protected]");
$mail->isHTML(true);

// Without AddEmbeddedImage the ical is shown
$mail->AddEmbeddedImage("/var/www/html/img/logo.png", "phpmailerlogo", "logo.png");

$mail->Subject = "Ical with AddEmbedded or AddAttachment not working";
$mail->Body    = 'Test Mail with Embedded Image and Ical<br/><img src="cid:phpmailerlogo" /><br/>Thanks for help.';

$ical_content = 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Mailer//Mailer Termin//DE
METHOD:REQUEST
BEGIN:VEVENT
UID:'.md5(uniqid(mt_rand(), true)).'
ORGANIZER;CN=Mailer:[email protected]
LOCATION:Berlin
SUMMARY:Test Event
DESCRIPTION:Problem
DTSTART:20210430T140000
DTEND:20210430T150000
DTSTAMP:20210416T140000
END:VEVENT
END:VCALENDAR';

$mail->AltBody = $ical_content;
$mail->Ical = $ical_content;

$mail->send();

Debug output

ical is missing

@Synchro
Copy link
Member

Synchro commented Apr 17, 2021

Is the iCal content actually sent in the message? Debug output with SMTPDebug = 2 will show that.

Also why are you disabling certificate verification? That's a dangerous thing to do, so you need to be sure exactly why you're doing it.

@Borsti26
Copy link
Author

Borsti26 commented Apr 17, 2021

Yes it seems so.

2021-04-18 09:21:39 SERVER -> CLIENT: 220 Exchange-01.xxx.local Microsoft ESMTP MAIL Service ready at Sun, 18 Apr 2021 11:21:38 +0200
2021-04-18 09:21:39 CLIENT -> SERVER: EHLO mail.xxx-wb.net
2021-04-18 09:21:39 SERVER -> CLIENT: 250-Exchange-01.xxx.local Hello [192.168.2.205]250-SIZE 37748736250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-X-ANONYMOUSTLS250-AUTH NTLM250-X-EXPS GSSAPI NTLM250-8BITMIME250-BINARYMIME250-CHUNKING250 XRDST
2021-04-18 09:21:39 CLIENT -> SERVER: STARTTLS
2021-04-18 09:21:39 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2021-04-18 09:21:39 CLIENT -> SERVER: EHLO mail.xxx-wb.net
2021-04-18 09:21:39 SERVER -> CLIENT: 250-Exchange-01.xxx.local Hello [192.168.2.205]250-SIZE 37748736250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH NTLM LOGIN250-X-EXPS GSSAPI NTLM250-8BITMIME250-BINARYMIME250-CHUNKING250 XRDST
2021-04-18 09:21:39 CLIENT -> SERVER: AUTH LOGIN
2021-04-18 09:21:39 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2021-04-18 09:21:39 CLIENT -> SERVER: [credentials hidden]
2021-04-18 09:21:39 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2021-04-18 09:21:39 CLIENT -> SERVER: [credentials hidden]
2021-04-18 09:21:39 SERVER -> CLIENT: 235 2.7.0 Authentication successful
2021-04-18 09:21:39 CLIENT -> SERVER: MAIL FROM:<[email protected]>
2021-04-18 09:21:39 SERVER -> CLIENT: 250 2.1.0 Sender OK
2021-04-18 09:21:39 CLIENT -> SERVER: RCPT TO:<[email protected]>
2021-04-18 09:21:39 SERVER -> CLIENT: 250 2.1.5 Recipient OK
2021-04-18 09:21:39 CLIENT -> SERVER: DATA
2021-04-18 09:21:39 SERVER -> CLIENT: 354 Start mail input; end with <CRLF>.<CRLF>
2021-04-18 09:21:39 CLIENT -> SERVER: Date: Sun, 18 Apr 2021 11:21:39 +0200
2021-04-18 09:21:39 CLIENT -> SERVER: To: [email protected]
2021-04-18 09:21:39 CLIENT -> SERVER: From: "XXX" <[email protected]>
2021-04-18 09:21:39 CLIENT -> SERVER: Subject: Ical with AddEmbedded or AddAttachment not working12
2021-04-18 09:21:39 CLIENT -> SERVER: Message-ID: <[email protected]>
2021-04-18 09:21:39 CLIENT -> SERVER: X-Mailer: PHPMailer 6.4.0 (https://github.com/PHPMailer/PHPMailer)
2021-04-18 09:21:39 CLIENT -> SERVER: MIME-Version: 1.0
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Type: multipart/alternative;
2021-04-18 09:21:39 CLIENT -> SERVER: boundary="b1_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8"
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: This is a multi-part message in MIME format.
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: --b1_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: BEGIN:VCALENDAR
2021-04-18 09:21:39 CLIENT -> SERVER: VERSION:2.0
2021-04-18 09:21:39 CLIENT -> SERVER: PRODID:-//Mailer//Mailer Termin//DE
2021-04-18 09:21:39 CLIENT -> SERVER: METHOD:REQUEST
2021-04-18 09:21:39 CLIENT -> SERVER: BEGIN:VEVENT
2021-04-18 09:21:39 CLIENT -> SERVER: UID:23fd85c3b58071fb3f3347056e5f5e45
2021-04-18 09:21:39 CLIENT -> SERVER: ORGANIZER;CN=Mailer:[email protected]
2021-04-18 09:21:39 CLIENT -> SERVER: LOCATION:Berlin
2021-04-18 09:21:39 CLIENT -> SERVER: SUMMARY:Test Event
2021-04-18 09:21:39 CLIENT -> SERVER: DESCRIPTION:Problem
2021-04-18 09:21:39 CLIENT -> SERVER: DTSTART:20210430T140000
2021-04-18 09:21:39 CLIENT -> SERVER: DTEND:20210430T150000
2021-04-18 09:21:39 CLIENT -> SERVER: DTSTAMP:20210416T140000
2021-04-18 09:21:39 CLIENT -> SERVER: END:VEVENT
2021-04-18 09:21:39 CLIENT -> SERVER: END:VCALENDAR
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: --b1_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Type: multipart/related;
2021-04-18 09:21:39 CLIENT -> SERVER: boundary="b2_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8";
2021-04-18 09:21:39 CLIENT -> SERVER: type="text/html"
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: --b2_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: Test Mail with Embedded Image and Ical<br/><img src="cid:phpmailerlogo" /><br/>Thanks for help.
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: --b2_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Type: image/png; name=logo.png
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Transfer-Encoding: base64
2021-04-18 09:21:39 CLIENT -> SERVER: Content-ID: <phpmailerlogo>
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Disposition: inline; filename=logo.png
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: iVBORw0KGgoAAAANSUhEUgAAAFUAAAAyCAYAAAAtBJe4AAAG3ElEQVR42u2bfWwTdRjHn7ZTdAiC
2021-04-18 09:21:39 CLIENT -> SERVER: ig5HoH90XXt9u2sdL4oyoS9DB9kLRcQEGazXLYPRDRViVCYvITGiRGMI/jnBSLsOyFQEnTBejBuL
2021-04-18 09:21:39 CLIENT -> SERVER: 7wGUIEbB14BGNAYHq8/THdmyrC/XXu+K6Td5suXud7+753PP737P77kr5JRTTjnllBm1gc0U0thr
2021-04-18 09:21:39 CLIENT -> SERVER: 2tRcXZuGWzbcwhp26Vtqe6AHihqD4NXAEJldvkqTy/cm4+RfMLn4Z81uviUThv2vY1y+bcyDPhNk
2021-04-18 09:21:39 CLIENT -> SERVER: SOE8zokM1obV3Oow+juShdTsE9QmCCUFEE/UCTbsR4vEsrfBGtkP5ldKS0vztBWBcSAIgXYjzIgc
2021-04-18 09:21:39 CLIENT -> SERVER: Znb6IgUVAS2g6OZ2gCNfMqDAPUB+JmshsN8fP1LV9iZseCVWB0G1PXIcdN2Ayl+4+jWLk7cMQuV7
2021-04-18 09:21:39 CLIENT -> SERVER: 5ILKuP3bQVA3FN8TVDn2tACoQQKFVNwBMVCDYJsK8URhHQtqCO19MGEn3ASDq37W5PKGPsc8Pl/u
2021-04-18 09:21:39 CLIENT -> SERVER: SDU7+ciEysaZIGgPsJui16exV6UdpRr2YepLHqhkKi7yMeg3A2pMdfMJCw5Br9erUWD4fwKCjoBl
2021-04-18 09:21:39 CLIENT -> SERVER: fEhtvxi9Pg3XA2kK+zgqG1Qa9ofA+COgtHNXTtfNrSfnflMCauG8hgAI6gDLM0OvEyNtccrDXsN6
2021-04-18 09:21:39 CLIENT -> SERVER: qQ/ZoLYDG+kC4yOAur0qcIiilHHx5+SGiue9nL/oqbsBdRp0o/Bmnx92rV9BisJjP5UNKkXpUTB0
2021-04-18 09:21:39 CLIENT -> SERVER: RYFWBmYbPH5yUBGo+rL6VhD0ATD+kZxEH/gUhv0yOlY2qBSlh6H4PgHqfowWRaDSecdWr/KAoLCK
2021-04-18 09:21:39 CLIENT -> SERVER: 643h6LdiMwE85hvZoFKUHoPi3VGg81aVGN3RKFUEqsHD9w5OUEZnKL6zzZCcKDdfScfIBpWi9BDo
2021-04-18 09:21:39 CLIENT -> SERVER: S4Qo3YHRIhFU3wHTHH8Z4/TXmN2+ZSMZtqs1uX2LzE5/ldVV++ho75MFIGg32FrjOYrAf05mQRAE
2021-04-18 09:21:39 CLIENT -> SERVER: 5kZsf042qCG0I6APR4GWNxVilPYTEEmguvnNkKIOAlOAI+ifhCsdNfs0JBD6uIbaygcV89Ju0M0A
2021-04-18 09:21:39 CLIENT -> SERVER: 1Liq5vUUpRJCfRlS1C6sSyTjLA7rizsxj4UY2gvFY7Ddr7JC/RCYfSCoqKzuDMLICqg4U3cl7zS7
2021-04-18 09:21:39 CLIENT -> SERVER: MXaU2luojTxQB9f48wF1S3VzNUVpNkANgrVYpNN/7QXzXTBMtNTGOsefskAVCiqRDrCeA0GT5jeE
2021-04-18 09:21:39 CLIENT -> SERVER: EERWQL1200XalhFSqM20TxaoNCRogsI0asO1CQoh9EkN1eziX8z40B+0vt3AakEQQijEbZdlg4rP
2021-04-18 09:21:39 CLIENT -> SERVER: oO1YOLncBQYLoMZXBHgzQpAWKpl/K5BaWtTUx0hG+3RzV45ivC03Dsz6Bm0azm8bEqWv0jbZoOKz
2021-04-18 09:21:39 CLIENT -> SERVER: dGsnMLtAkK6s/j1TRqDyl9DOUh+xDPdfwL9/TKwMGAF1GAxL03GeZvtWsI6m/2WF+g6wLE5QXDRK
2021-04-18 09:21:39 CLIENT -> SERVER: vY2TcYLqFwtVStN76i5oS5feBCis5bam4Tzl3RswzVqfQaiJpS1fUUOOKQl1cvmKzsEyn/VMmgCu
2021-04-18 09:21:39 CLIENT -> SERVER: kikK1eKs3ak01DsqV70EKHrGh1XkRPaZGKgqdOp7paHeVtlUA6iPoIjPFogpQ2U8dVPJKSWhMlgR
2021-04-18 09:21:39 CLIENT -> SERVER: m1jR6BAmqddlBNVPJjlUTM6blIZa5Kn/HYT+D4CpJ15FCiegXumgsm9QPix9pLr8u5SGWljecAxQ
2021-04-18 09:21:39 CLIENT -> SERVER: QZhx816w/R3Hse/awW7Ev6fTBUo3aAdMG4vFpE7JoaJTp5WGemdFYPtA0m+cnmCS6htYbdkXShCp
2021-04-18 09:21:39 CLIENT -> SERVER: dcIC4YSkUI2zl08hpzIM9QLaZ2gnhxvj5E9hftw3ekHzkoFJSr8kgWNXguC4VVjGHk8D6OdDVl0n
2021-04-18 09:21:39 CLIENT -> SERVER: JYVqcvo8mYfq2wJJqhNMGxNDtRUCqj2PdaUMVcM+lCmo9DxtHg5ByYJKUMW1JQtVALJTNFA8B6Ay
2021-04-18 09:21:39 CLIENT -> SERVER: AtXh4G+gYsdwCEqW/kIa9ogYqGHgpuC2f8VAbQebPmNQTZ7lOnR4X7ZApVfNeOE/iIEqQHkuWShY
2021-04-18 09:21:39 CLIENT -> SERVER: o90EqIxBZdz8NHS6J1ug0jsmqt6LhXoQSvNw+9kkoPw0+NY1U5Hq9i9Ap89nC1QalnThYqEKj43H
2021-04-18 09:21:39 CLIENT -> SERVER: Eh2LbWoBlVGo9K4d7VK2QA0Be2+qUAU4a/EV0Zc4Eb2LwzyISX2oTcV24PYvwmp2HaBkgOpfQ05n
2021-04-18 09:21:39 CLIENT -> SERVER: DdQ8mzt1qIklF9TnswkqrZKue6iUP2YTVPrhxnUPlXLUrIKqtvM5qBJDpe8Q/gdQfVtEFEXOD4WK
2021-04-18 09:21:39 CLIENT -> SERVER: kHulj1RutTJQ7aeSXpGBY1qiYsoGEVB/offyQ27IUTHv/SWEejUM1kkSR+rXyUcqNwPiyeLmDbQA
2021-04-18 09:21:39 CLIENT -> SERVER: MDt9C+m70FhmcvKLjS4/VXVUIIhx8jMxAh+n/fEs+k3qnForJCH6NR1e9CwaYiMZORQGtoS+MwUJ
2021-04-18 09:21:39 CLIENT -> SERVER: FQSHBW0mnSOWhcE+nfJo+pYAcsopp5wG9B/9gHVZYc8ZLAAAAABJRU5ErkJggg==
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: --b2_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8--
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: --b1_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8--
2021-04-18 09:21:39 CLIENT -> SERVER:
2021-04-18 09:21:39 CLIENT -> SERVER: .
2021-04-18 09:21:40 SERVER -> CLIENT: 250 2.6.0 <[email protected]> [InternalId=82149839470601, Hostname=Exchange-01.xxx.local] Queued mail for delivery
2021-04-18 09:21:40 CLIENT -> SERVER: QUIT
2021-04-18 09:21:40 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel

Thanks for the certificate hint, thats only for test case. But i want to send my complete used code, not that this cause the behavior.

@Synchro
Copy link
Member

Synchro commented Apr 18, 2021

I found your problem:

PHPMailer 5.2.16

Both the issue template and the troubleshooting guide tell you to make sure you're using the latest version. Meanwhile your application may be vulnerable to a serious RCE security hole, so I suggest you go update it.

@Synchro Synchro closed this as completed Apr 18, 2021
@Borsti26
Copy link
Author

Sorry i have two Server. And my First Log was from the old Version. I Use Version PHPMailer 6.4.0.
See the Log in my Last comment i updated.

@Borsti26
Copy link
Author

Borsti26 commented Apr 19, 2021

I compared now the log with and without Attachment.

b1 is the ical and with attachment it has no longer the Content-Type: text/calendar.

2021-04-18 09:21:39 CLIENT -> SERVER: --b1_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8
2021-04-18 09:21:39 CLIENT -> SERVER: Content-Type: multipart/related;
2021-04-18 09:21:39 CLIENT -> SERVER: boundary="b2_FtOMFVLQS6l8efsviFYtfouvCssROxOmQjRjwRpVz8";
2021-04-18 09:21:39 CLIENT -> SERVER: type="text/html"

Here without attachment which is working.

2021-04-19 08:31:53 CLIENT -> SERVER: --b1_vlHsq55Kppi7tlpNfr1UDiUxzY8qHeji7vRwYTGvsQE
2021-04-19 08:31:53 CLIENT -> SERVER: Content-Type: text/calendar; method=REQUEST; charset=UTF-8
2021-04-19 08:31:53 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit

This might be the problem !?

@Synchro
Copy link
Member

Synchro commented Apr 19, 2021

Very likely. If you look at the way that messages are constructed, there are just a few fixed combinations, and not all of them include calendar support. In this case you're ending up in the alt_inline_attach structure, which is indeed missing Ical support.

@Borsti26
Copy link
Author

Ok i understand.
Maybe, than to just attach the ical is the more trustable way.

Thanks.

@Synchro
Copy link
Member

Synchro commented Apr 19, 2021

Unfortunately iCal support across email clients is a mess, so using a simple attachment will work in some clients but not others – see #175 for some discussion and history on that.

@Borsti26
Copy link
Author

Ok, i see.
Thanks for your help.

Have nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants