In a custom moudule I find email addresses and return them as clickable mailto anchors on the page.

    $tableEntry['Email'] = l($emailAddress ,'mailto:'.$emailAddress , array('html' => TRUE)); 

    //Snippet of render array being used to create the table.. In a different function from the line above
    $rows = array();
    foreach ($tableEntries as $entry) {
    $rows[] = array(
        array('data' => $entry['Email']), //l($entry['Email'], 'mailto:'.$entry['Email'], array('absolute' => TRUE))),

If i create the anchors before passing them into the table's render array, Drupal does something to strip away the html. I have tried a whole bunch of argument options in l() and have also tried directly entering in HTML into l(), all the time the results get stripped. (I always check the generated email address to be sure it was first created successfully) . The only way i am able to get an anchor to display as a link within the browser, instead of plain text, is to call the l() function at the last step of building the table render array eg. the commented out code. Any explanations are much appreciated.

  • 1
    print l('[email protected]', 'mailto:[email protected]'); prints the mailto: link perfectly. I think it has to do something with your table. May be posting the table theme part will help. Any call to check_plain() or t() without proper modifiers will ruin the party.
    – AKS
    Apr 11, 2014 at 16:41

1 Answer 1


Just for sanity's sake...from a 'Drupal' point of view, your code works fine. For example (without the loop),

$emailAddress = '[email protected]';
$entry['Email'] = l($emailAddress ,'mailto:'.$emailAddress , array('html' => TRUE)); 

//Snippet of render array being used to create the table 
$rows = array();
$rows[] = array(
    array('data' => $entry['Email']),

print theme('table', array('rows' => $rows));


    <tr class="odd">
      <td><a href="mailto:[email protected]">[email protected]</a></td>

You may have a custom implementation of theme_table() somewhere which sanitises the incoming cell data, but it's not being caused by Drupal core.

Or, it might simply be that you're trying to re-use $entry when it doesn't make sense to.

$entry['Email'] = l($emailAddress ,'mailto:'.$emailAddress , array('html' => TRUE)); 


foreach ($tableEntries as $entry) {

Are you sure you meant to overwrite the outer $entry array with the one in the foreach?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.