Emailing some output
Posted: Sat Mar 01, 2008 11:23 am
Hey guys,
I have a script that is emailing the output of a php page using Swift Mailer. It is currently emailing the output as an html attachment but I am running into problems when my clients need to print the attachment. It seems that my page breaks aren't always working. I am guessing it is just because of different browsers out there and even different versions of the same browser.
Instead of banging my head against the wall and working on countless ways to write the same page break it seems the best way to fix the problem is to do a pdf attachment instead. The problem is that I really don't know where to start. Here is the code that I am using to get the content:
and then later I use this to mail it:
The invoice is produced based on a form that is filled out in the office when an invoice is ready to go.
The problem I am having is that all the pdf classes and modules I have looked at want to save the output into a file. The truth is that I am in uncharted waters (as usual) and I am looking for some direction.
Can I use the same setup and get a pdf attachment? Where would you recommend that I start? Is there something that I am missing that may be easier than the pdf route (text is out becuase they want a logo on it)?
Thanks for your time.
I have a script that is emailing the output of a php page using Swift Mailer. It is currently emailing the output as an html attachment but I am running into problems when my clients need to print the attachment. It seems that my page breaks aren't always working. I am guessing it is just because of different browsers out there and even different versions of the same browser.
Instead of banging my head against the wall and working on countless ways to write the same page break it seems the best way to fix the problem is to do a pdf attachment instead. The problem is that I really don't know where to start. Here is the code that I am using to get the content:
Code: Select all
$email=$rowcust['E_MAIL'];
$toname=$rowcust['E_MAIL'];
$htmlbody="html version of my email body";
ob_start();
include("invoice.php");
$htmlatt = ob_get_contents(); // adding output to the variable
ob_end_clean();}
Code: Select all
$message->attach(new Swift_Message_Part("Text version of the email body"));
$message->attach(new Swift_Message_Part($htmlbody, "text/html"));
$message->attach(new Swift_Message_Attachment($htmlatt, "NC_Farms_Invoices.html", "application/html"));
$to = new Swift_Address($email, $toname);
The problem I am having is that all the pdf classes and modules I have looked at want to save the output into a file. The truth is that I am in uncharted waters (as usual) and I am looking for some direction.
Can I use the same setup and get a pdf attachment? Where would you recommend that I start? Is there something that I am missing that may be easier than the pdf route (text is out becuase they want a logo on it)?
Thanks for your time.