Anyway thing I've almost found the solution, it seems when you do an attachment, it is basically then ignoring the previous specification of the email contents as you're now producing a multipart email? So re specifying this as per below includes the content as well as the attachment... Next problem I have though is that no matter what I do, it's coming through as plain text showing all html tags, rather than rendering as html... So if anyone has any tips on this glad to hear them while I'm reading up on it
Code: Select all
$mailBody = $this->getPartial('emailPartial', array('order_page1' => $order_page1, 'order_page2' => $order_page2, 'order_page3' => $order_page3), 'text/html');
//send the above $mailbody in an email using the SwiftMail plugin
try
{
// Create the mailer and message objects
$mailer = new Swift(new Swift_Connection_SMTP('smtp.XXX', '', ''));
//build the message
$message = new Swift_Message('New Order', $mailBody, 'text/html');
//cehck for attachment and attach to message
if (trim($filename) != ""){
$file_location = sfConfig::get('sf_upload_dir').'/'.$filename;
$mime_type = 'excel/ms-excel';
$message->attach(new Swift_Message_Part($mailBody));
$message->attach(new Swift_Message_Attachment(new Swift_File($file_location), $filename, $mime_type));
//Change file permissions so that we can delete it
if(chmod($file_location,0777)) {
$this->logMessage("Sucessful chmod on ".$filename, 'debug');
}
else{
$this->logMessage("Could not chmod ".$filename, 'err');
}
}
etc..