Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » Defining email attachement as a variable

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

Page: 1 2
Go to End
Author Topic: 2142 Views
  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Defining email attachement as a variable Link to this post

    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

  • dalesaurus
    Avatar
    Community Member
    283 Posts

    Re: Defining email attachement as a variable Link to this post

    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"
    );

    2142 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.