mcarbonneaux / yii-mail

Automatically exported from code.google.com/p/yii-mail
0 stars 0 forks source link

attach function #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. in a controller function to send a mail
2. when attaching a file that comes from 
CUploadedFile::getInstanceByName('fileupload')
3. and put the code in the 
$message->attach(Swift_Attachment::fromPath($uploadedFileName->tempName);

What is the expected output? What do you see instead?
Instead of working, it shows an error because it does not recognise the 
Swift_Attachment out of the "YiiMail" 

What version of the product are you using? On what operating system?
the last version on linux

Please provide any additional information below.
I found the code in this link:
http://stackoverflow.com/questions/7941398/yiimail-sending-attachment/7946416#79
46416

Original issue reported on code.google.com by di...@kiwity.com on 15 Dec 2011 at 6:03

GoogleCodeExporter commented 9 years ago
Hi!

I solved this, maybe could be useful for someone..

I added this function to the YiiMailMessage.php:

public function fileAttach($uploadedFile){
   $uploadedFileName = $uploadedFile->tempName;
   $swiftAttachment = Swift_Attachment::fromPath($uploadedFileName);
   return $this->message->attach($swiftAttachment);
}

and just have to call that function to attach the file in the email!

Original comment by di...@kiwity.com on 19 Dec 2011 at 2:57

GoogleCodeExporter commented 9 years ago
still have the problem?

Original comment by jorge.za...@gmail.com on 19 Jun 2013 at 6:49

GoogleCodeExporter commented 9 years ago
Thanks, that fixed this error:

include(Swift_Attachment.php): failed to open stream: No such file or directory

with the code from the above link.

Original comment by u...@sansculotte.net on 28 May 2014 at 11:06

GoogleCodeExporter commented 9 years ago
I have the same problem.
Did you find any solution?

Original comment by igor...@gmail.com on 2 Jun 2014 at 2:31