How to make email into email links with mailto

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

How to make email into email links with mailto

Post by amir »

Hello,
I am updating contact_us table from Admin Panel and displaying that to Public Panel. I am giving information like Feedback as

Myself ~ Web Master
webs@mail.com

What I want is when I give an email in this string, then that should become an email link to that email address with mailto:

TIA!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

if you poked around a little for some email regular expressions, you'll find this is easily accomplished.

Hint.. preg_replace()

If your feeling really adventurous, check out the phpbb bbcode processor.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Is
Myself ~ Web Master
webs@mail.com
The actual format of the string? Can you clarify exactly what you are dealing with here?
amir
Forum Contributor
Posts: 287
Joined: Sat Oct 07, 2006 4:28 pm

Post by amir »

For example, i am entering a string My name and then my email like

Mr. Developer
info@domain.com

then I want that script should deal the normal string " Mr. Developer " as normal and it should make email a link with mailto:

Thanks!
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

amir wrote:For example, i am entering a string My name and then my email like

Mr. Developer
info@domain.com

then I want that script should deal the normal string " Mr. Developer " as normal and it should make email a link with mailto:

Thanks!
Again, a simple preg_replace, adding the <a> </a> tags around the match. Feel free to do a bit of research as we've had countless talks about email regular expression. :?
Post Reply