php - Sending <a> tag in body of email with Swift Mailer -


i new swift mailer , include link in body of html message linking home page however, php script not run when include anchor tag in message (the script work when include different element, such heading tag. not sure might missing.

php:

 <?php require_once '../swift/lib/swift_required.php';      // create transport     $transport = swift_smtptransport::newinstance()     ->setusername('admin@mazihealth.com')     ->setpassword('adminxxxx');      // create mailer using created transport       $mailer = swift_mailer::newinstance($transport);       $message = swift_message::newinstance();       $message->setsubject('my subject');       $message->setfrom('abc@mazihealth.com');       $message->setto('abc3@gmail.com');       $cid = $message->embed(swift_image::frompath('images/mazifinal_email.jpg'));       $message->setbody(       '<html>' .       ' <head></head>' .       ' <body>' .       ' message' .       '<a href="'http://www.mazihealth.com'">sign in</a>'.       ' </body>' .       '</html>',       'text/html' // mark content-type html       );      // send message       $result = $mailer->send($message);        echo $message->tostring();        ?> 

you have syntax error. remove single quotes in href:

$message->setbody(     '<html>' .     ' <head></head>' .     ' <body>' .     ' message' .     '<a href="http://www.mazihealth.com">sign in</a>'.     ' </body>' .     '</html>',     'text/html' // mark content-type html ); 

additionally, might find easier use heredoc statements outline content. makes reading/editing large strings easier. here example:

$body = <<<eod <html>     <head></head>     <body>         message .         <a href="http://www.mazihealth.com">sign in</a>     </body> </html> eod;  $message->setbody(     $body,     'text/html' // mark content-type html ); 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -