MainelyDesign.com Blog

Making Valid Email (mailto) links in CakePHP

Posted on 08/25/2009 at 04:59 pm by Kevin Wentworth
Viewed 15,570 times | 0 comments

It's easy to make an email address using the HTML's helper link() function.  All you need to do is have an email address appended with the string 'mailto:' (just like in regular ol' HTML).

Here's my quick and dirty function to attach it if it doesn't exist:

  1. if(stristr($image['link'], '@') and stristr($image['link'], 'mailto') === false) {
  2.     $address = 'mailto:'. $image['link'];
  3. } else {
  4.     $address = $image['link'];
  5. }
  6.  
  7. echo '<p>'. $html->link($image['link'], $address) . '</p>';

I hope this helps someone besides my forgetful brain. Cheers,

-Kevin Wentworth

Bookmark and Share

Tags for Making Valid Email (mailto) links in CakePHP

Cakephp | Web Programming | Usage

Comments for this Posting

No comments. Be the first to post a reply.

Sorry, comments are closed for this posting.

Please Email Kevin if you have any questions. Thanks!

Meet Site Avenger - Hosted Content Management System

Powered By: Site Avenger | Site Production: Saco Design