QEmailServer with QEmailAttachment

Login or register to post comments
5 replies [Last post]
LaCeja's picture
Offline
Joined: 11/04/2009

I'm having a problem using QEMailServer with a QEmailAttachment. When the email is sent the attachment is being sent as a string of base64 encoded data, rather than an attached file. Here's the relevant code:

$objAttachment = new QEmailAttachment($filenamepath,QMimeType::Pdf,$txtReportName);
    $objMessage->AddAttachment($objAttachment);

$filenamepath contains the full path name to the file and $txtReportName contains the filename. What am I missing here?

Thanks.

Steven Warren's picture
Offline
Joined: 11/06/2008

This is working code I have in production

$attCreditAuth = __DOCROOT__ . __SUBDIRECTORY__ . '/docs/Credit_Auth_one_time.pdf';
$strMessage = Blurb::LoadByShortDescription('FNMA_REQ_EMAIL_TEXT')->LongDescription;
$objMessage = new QEmailMessage(__ADMIN_EMAIL__, $objUserAccount->EmailAddress, 'FNMA Credentials Request', $strMessage);
$objMessage->HtmlBody = $strMessage;
$objMessage->Attach($attCreditAuth, QMimeType::Pdf, 'Credit_Auth_FNMA_REQ_' . $objUserAccount->Username . '.pdf');
AFCEmailServer::Send($objMessage);

LaCeja's picture
Offline
Joined: 11/04/2009

Steven:

I'm still getting the same results. I notice you're calling AFCEMailServer. Do you have a modified version of QEMailServer?

alex94040's picture
Offline
Joined: 11/06/2008

QEmailServer is being retired from the framework due to its terrible instability (see http://trac.qcu.be/projects/qcubed/ticket/654). I personally switched to PHPMailer. Vexed switched to Zend_Mail. I recommend you do the same.

Steven Warren's picture
Offline
Joined: 11/06/2008

LaCeja, AFCEMailServer overrides QEMailServer and initializes a few variables. I am having no issues with that code with QCubed 1.1.2 running on both Windows(dev) and Ubuntu(prod).

LaCeja's picture
Offline
Joined: 11/04/2009

There should be a note in the examples telling us that, so we don't spend a huge amount of time trying to make it work.