Does anyone know how to use the l() or url() function to create mailto links?
I am running drupal 6.
You need to use the absolute option:
l('Mail me', 'mailto:jim@hotmail.com', array('absolute' => TRUE));
will generate
<a href="mailto:jim@hotmail.com">Mail Me</a>
A good practice is to use the t() function with strings. Code should be then:
l(t('Mail me'), 'mailto:jim@hotmail.com', array('absolute' => TRUE));
Preferably none:
l() is useful for the output of internal links:
it handles aliased paths and adds an 'active' class attribute to links that point to the current page (for theming)" see reference
You need none of the above. Same goes for url(). You CAN use them, but why not keeping it simple and just use the HTML anchor tag directly.
来源:https://stackoverflow.com/questions/1460100/drupal-use-l-or-url-function-for-mailto-links