View Full Version : Automated Email with PDF attached
rosschapman
November 6th, 2007, 15:01
Hi,
Quite a difficult one here, so bear with me:
My client wants a Contact Form. On the contact form, there's a button users can tick called "Send me a prospectus". When the user submits the form, my client wants the form information emailed to him. Users that have ticked "Send me a prospectus" will get an automated message with a prospectus attached.
Can this be done?
thanks,
Corey Bryant
November 6th, 2007, 17:37
Somewhat like an auto-reply I would imagine? And using if box checked, then generate this email as well. .NET, ASP (JMail, ASPEMail, ASPMail, CDOSYS, etc), or PHP?
rosschapman
November 6th, 2007, 17:55
PHP ideally. If the box is unchecked, no automated message need be sent.
Corey Bryant
November 7th, 2007, 22:56
I wished I could offer some help but unfortunately I know nothing about PHP (except how to code the includes). I was mainly hoping to get the ball rolling with the others and get some ideas.
Maybe another way to possibly do it is to create to processing pages and have the form choose the correct (processing) page when the form is submitted. That way if they choose yes, then it goes to one page and if they choose no, it goes to another
Danny
November 7th, 2007, 23:17
Ross,
You couldnt create the form that takes the user to a thankyou page with a link to the pdf download if they requested it? Would that not be easier - although it would have an effect on your bandwidth dependant on the file size.
Danny
Dead6re
November 14th, 2007, 15:36
For sending attachments in PHP, it is best to have a hard copy stored on the web server.
You can then read the file
$pdf = "./prospectus.pdf";
$fhandler = fopen($pdf, 'rb');
$contents = fread($fhandler, filesize($pdf));
fclose($fhandler);
Now to attach it to the e-mail
$rand = md5(time());
$mime = "==Multipart_Boundary_x{$rand}x";
$headers .= "
\nMIME-Version: 1.0\nContent-Type: multipart/mixed;\nboundary=\"{$mime}\"
";
$mymsg = "Your message goes here.";
$message = $mymsg."\n\n
--{$mime_boundary}\n
Content-Type: text/plain; charset=\"iso-8859-1\"\n
Content-Transfer-Encoding: 7bit\n\n
$message\n\n
";
$attachment = chunk_split(base64_encode($contents));
$message .= "--{$mime}\n
Content-Type: {application/pdf};\n
name=\"{prospectus.pdf}\"\n
Content-Disposition: attachment;\n
filename=\"{prospectus.pdf}\"\n
Content-Transfer-Encoding: base64\n\n
$attachment\n\n
--{$mime}--\n
";
rosschapman
November 20th, 2007, 21:22
Hi Dead6re,
I'm using the FormM@iler 4.x PHP Form Mail Script.
I'm now thinking that the user ticks a box and then goes to a different thankyou (formmailer.php) page. Any ideas?
The contact form just uses for <form> code and the thankyou uses php to send. Trying to work it out myself, but getting a little lost...
thanks,
Edit1: Better way of putting it:
If a tick box in form is ticked, send email. Auto-respond to form submission with PDF file attached.
If tick box in form is not ticked, send email.
Edit2: I think I've worked it out. I need to modify the send_copy settings.
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.