Skip to content

Instantly share code, notes, and snippets.

@dragoonis
Created May 2, 2011 10:37
Show Gist options
  • Save dragoonis/951422 to your computer and use it in GitHub Desktop.
Save dragoonis/951422 to your computer and use it in GitHub Desktop.
<?php
// Do we have attachments ?
if($attachment !== null) {
// If its a singular string based attachment we convert it to conform with the generic attachment structure
if(!is_array($attachment)) {
$attachment = (array) $attachment;
}
// Attach all of our attachments
foreach($attachment as $att) {
// If its an array and we have 'title', 'path' then we can add the attachment and rename it.
if(is_array($att) && isset($att['title'], $att['path'])) {
$message->attach(
Swift_Attachment::fromPath($att['path'])->setFilename($att['title'])
);
// Standard attach
} else {
$message->attach(Swift_Attachment::fromPath($att));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment