Created
January 4, 2016 10:36
-
-
Save vojtasvoboda/aac55e1a9b76ddc33f03 to your computer and use it in GitHub Desktop.
Send mail with attachments in OctoberCMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$email = '[email protected]'; | |
$template = 'my.plugin::mail.recordform'; | |
$templateParameters = ['site' => 'mysite.cz']; | |
$attachments = []; | |
foreach($record->images as $image) { | |
$attachments[] = $image; | |
} | |
Mail::send($template, $templateParameters, function($message) use ($email, $attachments) | |
{ | |
foreach($attachments as $attachment) { | |
$params = ['as' => $attachment->getFilename()/*, 'mime' => $mime*/]; | |
$message->attach($attachment->getLocalPath(), $params); | |
} | |
$message->to($email); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, i've tried your code but i have a problem, i get only the last file attached to my email, even tough i'm uploading to the form more than one file, this is the code that im using to send the files to the emial.
`$attachments = [];
foreach($cliente->galeria as $image) {
$attachments[] = $image;
}
`
Do you have any idea as to why i'm only getting one file? thank you.