SwiftMailer - Adding PHP elements to the Message Body -


i trying make body of mail [huge concatenation]

$body='<table  border=1>'.'<tr>'.'<th>description</th>'.'<th>quantity</th>'.'<th>cost</th>'.'</tr>'; for($x=0;$x<=$length-1;$x++)     {     $body .='<tr>'.'<td>'.$json2[$x]["description"].'</td>'.'<td>'.$json2[$x]["qty"].'</td>'.'<td>'.$json2[$x]["cost"].'</td>'.'</tr>';     }  $body.='</table>'; 

and send using swift mailer

$message = swift_message::newinstance('thanks order') ->setfrom(array('abc@gmail.com' => 'sender'))  ->setto(array('xzy@gmail.com' => 'receiver name'))  ->setbody($body,'html'); 

the mail received table not seen.

for feroz

 $mailer = swift_mailer::newinstance($transport);  $message = swift_message::newinstance('dialswap - order')  ->setfrom(array('rorrykeys2@gmail.com' => 'dialswap'))   ->setto(array('rorrykeys@gmail.com' => 'receiver name'))   ->setbody($body,'text/html');  $headers = $message->getheaders();  $headers->addtextheader('content-type', 'text/html'); 

html not valid content-type:

->setbody($body,'html'); 

you want text/html.

you can find usage examples in creating messages chapter.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -