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

PDF attachment is missing in e-mails #3

Closed
djzwerg opened this issue Sep 21, 2021 · 12 comments
Closed

PDF attachment is missing in e-mails #3

djzwerg opened this issue Sep 21, 2021 · 12 comments

Comments

@djzwerg
Copy link

djzwerg commented Sep 21, 2021

When PDF attachment is actived it won't be sent. The recipient only gets a lot of unreadable symbols at the end of his/her mail.

I tried MIME mail and SMTP mail in combination with Mail System.

Note: This was further mentioned at #1 but I think it's a different issue.

@djzwerg
Copy link
Author

djzwerg commented Sep 22, 2021

I'm not sure whether this issue is caused by webform2pdf or one of the mail modules (e. g. look at backdrop-contrib/mimemail#25). So I will try other mail engines like PHP mailer to check this out.

@djzwerg
Copy link
Author

djzwerg commented Sep 22, 2021

I've tried PHP mailer and different settings but it doesn't work. When the PDF attachment to webform mails is activated the layout of the mail gets broken.

This line will be added to the body before the content:
grafik

Instead of attaching the PDF file the end of the body looks like this:
grafik

@mazzech
Copy link

mazzech commented Oct 7, 2021

I had the same problem, but found a workaround: let users download the PDF. Put this one into the confirmation e-mail body field, make sure that it has an access token

<a href="https://yourdomain.com/node/((your webform's node ID))/submission/[submission:sid]/downloadpdf?token=[submission:access-token]">Download PDF</a>

Hope this helps...

@djzwerg
Copy link
Author

djzwerg commented Oct 7, 2021

@mazzech I think that shouldn't be a workaround. Because of Europe's GDPR it won't be compliant to have public access to these documents.

@mazzech
Copy link

mazzech commented Oct 7, 2021

The access token makes it secure enough for my purposes. Any webform submission can be accessed through a tokenized URL. I just thought I share it if anyone is interested;-)

@bugfolder
Copy link
Collaborator

So I just tried this out, setting up a simple form on a live Backdrop site and a simple attached PDF and it worked: I received the email with the attached PDF, and the PDF was valid (opened and contained contents). The raw content of the mail body looked like this:



--------------f1e7c9662b0e70521404aac413c8bd62
Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes
Content-Transfer-Encoding: 8bit

Submitted on Friday, October 8, 2021 - 11:17am
Submitted by user: example
Submitted values are:

Dummy field: Dummy field content 2


The results of this submission may be viewed at:
https://example.com/node/3/submission/5

--------------f1e7c9662b0e70521404aac413c8bd62
Content-Type: application/pdf; name="webform_submission-3-5.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="webform_submission-3-5.pdf"

JVBERi0xLjYKJeLjz9MKNiAwIG9iago8PCAvVHlwZSAvUGFnZSAvUGFyZW50IDEgMCBSIC9MYXN0
TW9kaWZpZWQgKEQ6MjAyMTEwMDgxMTE3NTUtMDcnMDAnKSAvUmVzb3VyY2VzIDIgMCBSIC9NZWRp
YUJveCBbMC4wMDAwMDAgMC4wMDAwMDAgNTk1LjI3NjAwMCA4NDEuODkwMDAwXSAvQ3JvcEJveCBb
...

Could you try setting up the simplest possible form (like, 1 field) and the simplest possible PDF (e.g., just a text header and default content) and see if that works? Maybe we can narrow down the issue you're seeing.

@mazzech
Copy link

mazzech commented Oct 8, 2021

Hi @bugfolder, thank you for chiming in... my comment was not be clear enough... I was talking about sending HTML(!) mails with attached PDF (which did not work). It works perfectly when sending text-only mails from the webform module, but this was not an option in my project, for a number of reasons.

@bugfolder
Copy link
Collaborator

OK, thanks for clarifying. As a point of reference, (a) which HTML mail module(s) were you using, and (b) had you previously successfully used the D7 version(s) of those modules with D7 Webform2PDF?

@mazzech
Copy link

mazzech commented Oct 9, 2021

Hi @bugfolder, I use Mime Mail for getting the HTML mails created, and no, I never tried this on D7... but here's an interesting one: https://www.drupal.org/project/webform2pdf/issues/2911898 and here https://www.drupal.org/project/webform2pdf/issues/2914369

@bugfolder
Copy link
Collaborator

Hi @mazzech, thanks for those links. They're interesting, but even with installing and using the Mime Mail module, I'm still getting PDFs successfully generated, attached, and received, now with HTML mail.

Here's what I have for the Webform module settings:
webform_module_settings

Here's the Mime Mail module settings:
mimemail_module_settings

And here's the individual webform email settings:
individual_webform_email_settings

The result is successfully sent and is received as an email with a valid PDF attachment. Here's the top of the email body:


--------------910d1e9a08a7288a55abbef96cec4813
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
Submitted on Saturday, October 9, 2021 - 10:45am

Submitted by user: example

Submitted values are:

Dummy field
     Dummy field content
The results of this submission may be viewed at:

https://example.com/node/3/submission/9

--------------910d1e9a08a7288a55abbef96cec4813
Content-Type: application/pdf; name="webform_submission-3-9.pdf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="webform_submission-3-9.pdf"

JVBERi0xLjYKJeLjz9MKNiAwIG9iago8PCAvVHlwZSAvUGFnZSAvUGFyZW50IDEgMCBSIC9MYXN0
TW9kaWZpZWQgKEQ6MjAyMTEwMDkxMDQ1MTItMDcnMDAnKSAvUmVzb3VyY2VzIDIgMCBSIC9NZWRp
YUJveCBbMC4wMDAwMDAgMC4wMDAwMDAgNTk1LjI3NjAwMCA4NDEuODkwMDAwXSAvQ3JvcEJveCBb
<snip>

Now, there appears to be something amiss because although I have selected "Full HTML" as the Mime Mail setting, the HTML tags are getting stripped out of of the text/html content. But the PDF attachment is coming through.

So, could you compare your settings with what I have above, see if there are differences, and/or if any of those differences have any effect?

@robertgarrigos
Copy link
Member

There was a bug within mimemail. There's a PR for it.

@bugfolder
Copy link
Collaborator

Doing a bit of housekeeping, since it appears the underlying issue was in the MimeMail module, I'm closing this issue.

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

4 participants