Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Defining email attachement as a variable


Go to End
Reply


10 Posts   2364 Views

Avatar
mschiefmaker

Community Member, 187 Posts

19 September 2009 at 3:02pm

A repeat on an earlier issue, changing to

$fn = DataObject::get_by_id("MonkeysFist", 7);
$filepath = "assets/Uploads/mf_attachments/$fn->MFFileName";
$emailToSubmiter->attachFile($filepath, $fn->MFFileName);

Fixes it

Avatar
dalesaurus

Community Member, 283 Posts

19 September 2009 at 3:37pm

Bizarre stuff, indeed. If any other attachments get cheeky you may want to get a little more hands on and ensure the encoding, contents, and mime type are specified. With certain finicky MUAs out there, sometimes you must apply some thorough beatings until they yield.

An example from the codes:

$email = new Email();
$email->attachments[] = array(
'filename' => BASE_PATH . "/themes/mytheme/images/header.gif",
'contents' => file_get_contents(BASE_PATH . "/themes/mytheme/images/header.gif"),
'mimetype' => 'image/gif',
'contentLocation' => Director::absoluteBaseURL() . "/themes/mytheme/images/header.gif"
);

Go to Top