Problem With Mail Extension And tcpdf

Hi All

I am working on a site in which I have two links on the top of every page. Pdf and Mail. The functionality desired from these links is …

On clicking the Pdf link the user should be getting the pdf created for that page. I am using tcpdf extension for creating the pdf.

Now the other link is Mail link. On clicking the mail link one dialog box opens and the user fills the email id’d\s on which the mail should be sent . On clicking the submit button an email should be sent with the Pdf report generated for that page.

I am quite Ok with the pdf creation part but on sending mail I am quite stucked up.

I downloaded the mail extension and read the documentation provided in YiiMail.php and YiiMailMessage.php

Then I tried using it with the help of sample example given in YiiMail.php.

I have read in the documentaion of tcpdf is that if we pass E in the last argument of function Output then it returns the document as base64 mime multi-part email attachment

This is the action that I have written in my controller

		$STRING = $pdf->Output($_SESSION['htmlTitle'].'.pdf', "E");


		$message = new YiiMailMessage;


		$sendingMessage = new YiiMail;


		


		$message->setBody('Message content here with HTML', 'text/html');


		$message->subject = 'My Subject';


		//$message->attach($STRING);


		$message->addTo('vatspande@gmail.com');


		$message->from = 'vatsal.p@vedainformatics.com';


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


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


			echo '1';exit;


		}else{


			echo 'Some Problem';exit;


		}

But I am getting an error :

Property "CWebApplication.mail" is not defined.

Is there something needs to be added in my config.php ??

Any help is appreciated…

Kindly Help

Regards

Did you add YiiMail as a component to your config?

No I haven’t. Can u please tell me what do I need to add

I have added mail component in my config.php and the first error that was coming

Property "CWebApplication.mail" is not defined.

has gone now :rolleyes:

I am trying to use attach function like this

$STRING = $pdf->Output($_SESSION[‘htmlTitle’].’.pdf’, “E”);

$message->attach($STRING);

The method Output return the document as base64 mime multi-part email attachment

So now I am getting an error

Argument 1 passed to Swift_Mime_SimpleMessage::attach() must implement interface Swift_Mime_MimeEntity, string given

So in which direction should I proceed???

Any help???

Regards

I am guessing wildly - because I haven’t got any source to look at right now - but try and construct a new Swift_Mime_MimeEntity from the output of your pdf create function.

Then pass that to Swift, instead of the string.

Something which is a "base64 mime multi-part email attachment", not a string.

Look in the Swift directory of Yii-mail.

I can’t help you more than that, I’m afraid. :)

Hi All

I have read the documentation of tcpdf again and it says that the output function when used with "E" as second argument then it "returns the document as base64 mime multi-part email attachment"

Now I am trying to pass this to the attach function provided by yii-mail extension.

"Argument 1 passed to Swift_Mime_SimpleMessage::attach() must implement interface Swift_Mime_MimeEntity, string given "

This is what I am doing :

    $STRING = $pdf->Output($_SESSION['htmlTitle'].'.pdf', "E");


    $message = new YiiMailMessage;


$sendingMessage = new YiiMail;


 $message->setBody('Message content here with HTML', 'text/html');


 $message->subject = 'My Subject';


 $message->attach($swift);


 $message->addTo('vatspande@gmail.com');


 $message->from = 'vatsal.p@vedainformatics.com';


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


     echo '1';exit;


 }

With This piece of code normal text content without attachment is going without any problem but when I use attach function then it is giving the error that is mentioned above.

What should I do now. As per the above reply he is saying me to try and construct a new Swift_Mime_MimeEntity from the output of pdf create function.

Then pass that to Swift, instead of the string.

Something which is a "base64 mime multi-part email attachment", not a string.

But with the output function I am already getting a base 64 mime multipart email attachment.

So how can I change it to Swift_Mime_MimeEntity.

I am stuck on this from quite a while now…

Any help is highly appreciated

Regards

$message = new YiiMailMessage;

                    …


                    $message->attach(Swift_Attachment::fromPath(Yii::getPathOfAlias('webroot').Yii::app()->theme->baseUrl."/images/logo.png"));


                    …


                    $message->setBody(array('data'=>$data), 'text/html');


                    …


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