CFLib.org – Common Function Library Project

EmailAntiSpam(EmailAddress [, Mailto])

Last updated May 2, 2002

Version: 2 | Requires: ColdFusion 5 | Library: StrLib

 
Rated 0 time(s). Average Rating: 0

Description:
When given an email address this function will return the address in a format safe from email harvesters.

Return Values:
Returns a string

Example:

view plain print about
<CFOUTPUT>
#EmailAntiSpam("sduffey@ci.davis.ca.us")#<BR>
#EmailAntiSpam("sduffey@ci.davis.ca.us", "Yes")#<BR>
</CFOUTPUT>

Parameters:

Name Description Required
EmailAddress Email address you want to make safe. Yes
Mailto Boolean (Yes/No). Indicates whether to return formatted email address as a mailto link. Default is No. No

Full UDF Source:

view plain print about
<cfscript>
/**
 * When given an email address this function will return the address in a format safe from email harvesters.
 * Minor edit by Rob Brooks-Bilson (rbils@amkor.com)
 * Update now converts all characters in the email address to unicode, not just the @ symbol. (by author)
 * 
 * @param EmailAddress      Email address you want to make safe. (Required)
 * @param Mailto      Boolean (Yes/No). Indicates whether to return formatted email address as a mailto link.  Default is No. (Optional)
 * @return Returns a string 
 * @author Seth Duffey (rbils@amkor.comsduffey@ci.davis.ca.us) 
 * @version 2, May 2, 2002 
 */

function EmailAntiSpam(EmailAddress) {
    var i = 1;
    var antiSpam = "";
    for (i=1; i LTE len(EmailAddress); i=i+1) {
        antiSpam = antiSpam & "&##" & asc(mid(EmailAddress,i,1)) & ";";
    }
    if ((ArrayLen(Arguments) eq 2) AND (Arguments[2] is "Yes")) return "<a href=" & "mailto:" & antiSpam & ">" & antiSpam & "</a>"
    else return antiSpam;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson