Add Attachments To Send Mails

Hi,

I am using YiiMail extension for sending mails.

How can I add attachments to send mails?

refer its docs or use YiiMailer it uses phpmailer and they provide good api using it

I recommend looking into SwiftMailer.

I have the following code and it doesnt seem to work–

I dont know what does that "tempName" would mean here.

controller-

        $message = new YiiMailMessage;


        $message->Body=$_POST['ContactForm']['body'];


        $message->subject = $_POST['ContactForm']['subject'];


        $message->addTo($_POST['ContactForm']['email']);





        $uploadedFile = CUploadedFile::getInstanceByName('filename'); // get the CUploadedFile


        $uploadedFileName = $uploadedFile->tempName; // will be something like 'myfile.jpg'


        $swiftAttachment = Swift_Attachment::fromPath($uploadedFile); // create a Swift Attachment


        $this->email->attach($swiftAttachment); // now attach the correct type


  





        $this->actionContact();


        $message->from = "from@example.com";//Yii::app()->params['adminEmail'];





        if(Yii::app()->mail->send($message) )





        {


            echo 'mail sent';


        }


        else


            echo 'error while sending email';