PHP: How to send mail as a PDF? - php

I have a client questionnaire form with several input fields. When the form is submitted, I would like the message to be sent to me as a PDF. Is this possible? If so, does anyone have any references or links to point me in the right direction.

Those are a some quite different problems in one question.
How to generate a pdf.
Check out FPDF.
How to send mail with attachments.
For that you will need to send a multi-part message. A part that is different from the main e-mail can contain the PDF. It will need a correct mime type to be treated as such. An example is here.
The mime type of PDF, which is application/pdf.
I assumed you got the part with the questionnaire itself working already.

Related

Multi-lines sent from html is not writing in pdf using fpdf

I have textarea field in html which stores address information with multi lines (enter key pressed). I am sending that to a PHP file which then, the PHP file creates a PDF file using fpdf.php. Everything is fine except the addresses are printed in a single line in PDF file... Please help me.
Found the answer after lots of search and R&D... you have to use write method in fpdf to solve this.. Thanks for time friends

PHP - Embed Generated Image from External File into HTML email

I have a sign-up form. When someone signs up, they immediately receive an email (in HTML format) with the following information:
1) Their sign-up information (Name, P#, Email, etc.)
What I need is the following:
1) After sign-up, in the email the user receives, there needs to be a png-image that is generated by an external script. At the moment, I am using PEAR to generate/send the email (AOK) and Mail_Mime::addHTMLImage() to add the image, but alas, with no luck. All I get when I send the email is a broken image with my alt text appearing. It's important to keep in mind that I am generating the image (to be used in the HTML email) from an external script.
The code I'm using to try and grab the image (from the external script) is as follows:
$mime->addHTMLImage(get_template_directory_uri()."/qr_code_generator.php?code=", "image/png");
Also, not sure if it helps, but I'm using http://phpqrcode.sourceforge.net/ for the QR code generation
Any and all help is greatly appreciated!
I answered most of this in your previous question here.
The likely issue again is that you can't embedded base64 encoded images directly into the body of the email, you have to treat them like attachments. The way you do that is with a content section and an appropriate content id.
Check out the documentation for the addHTMLImage method.
https://pear.php.net/manual/en/package.mail.mail-mime.addhtmlimage.php
It's not the best documentation but check it out and my other answer. That should give you enough to solve the issue.

PHP+HTML webform to be emailed in PDF format as attachment

I recently have a project, I am creating a booking system.
there's only one thing that I need to do to finish it.
I want my web form to be converted into a dynamic PDF file.
Means, when a user makes a booking, he will fill up the web form, after all fields are filled up, it will be saved to the database and the web form will be converted to PDF that will be email to the client's email address.
Is there a plug-in that I need to use? How can I make my form be converted to PDF and be sent to user??
If there is, can you kindly give me a link to it?
I would gladly appreciate any help from you guys.
Thanks
You can use the libary TCPDF to accomplish this. The libary can create a PDF from HTML including HTML forms. Look at this example, it will help you farther:
PDF Example: http://www.tcpdf.org/examples/example_014.pdf
PHP tutorial of PDF example: http://www.tcpdf.org/examples/example_014.phps
Download link of TCPDF: http://sourceforge.net/projects/tcpdf/files/

Excel form on a web page

I'm working on a project a little special and I have to insert an excel form on a web page so that users can fill it online and then on submit it have to be sent by email (as attachment or form) to the recipient of the form.
The company has no skydrive and the form must be an excel and not an HTML form.
Does anyone have an idea?
Thanks all !
I'm the creator of Appizy (http://appizy.com) that aims at converting Excel files into dynamic webapp. If I get it well you could generate your HTML form based on Excel Spreadsheet with Appizy.
Then you "just" need to plug a submit button to the generated webapp to send the data by email.
PHPExcel seems to offer a fully fledged engine for PHP (including calculating ability).
There doesn't seem to be any clear cut examples of how to interact with it via a webpage however.

PHP mail() and image display in email client [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
php image display without download in mail
I have a PHP web application which create wishes card and send them with the PHP mail() function.
The wishes card is build with HTML and part of the card are illustrations, those illustrations use jpg images inside an IMG tag. The images are hosted on a server so images paths use a complete link (like http:/domain.com/img.jpg).
When the card is received, for exemple with thunderbird, it says images are blocked and the user has to click on a button to show the images.
I understand it's a security mesure.
That's still annoying for a whishes card which is meant to be discover with its illustrations.
So, i'm looking for any though, any light, in a way to prevent email clients from blocking images.
Thanks.
Image blocking is done on the receiver's end, by the mail client. There's nothing you can do about it.
It is because of this that you often see the
Can't see this email? View it here
(Or something similar) at the top of many emails. This is your best alternative.
Embed the image in the email, I strongly recommend something like phpMailer to do this.
From their documentation:
Inline Attachments
There is an additional way to add an attachment. If you want to make a
HTML e-mail with images incorporated into the desk, it's necessary to
attach the image and then link the tag to it.
For example, if you add an image as inline attachment with the CID
my-photo, you would access it within the HTML e-mail with &ltimg
src="cid:my-photo" alt="my-photo" />.
In detail, here is the function to add an inline attachment:
$mail->AddEmbeddedImage(filename, cid, name); By using this function
with this example's value above, results in this code:
$mail->AddEmbeddedImage('my-photo.jpg', 'my-photo', 'my-photo.jpg ');

Categories