Forum Moderators: coopster
Release Announcement [php.net]
ChangeLog [php.net]
/*********************************************************************
// Name: int FormatEmailAddress
// Input:
// Output:
// Description: Formats the email address to remove any content ouside
// of the angle brackets < > as per RFC 2821.
//
// Returns the invalidly formatted mail address if the < > are
// unbalanced (the SMTP server should reject it if it's out of spec.)
//
// Author/Date: garretts 08/18/2009
// History:
//********************************************************************/
static int FormatEmailAddress(char* Buffer, char* EmailAddress, char* FormatString) {
char *tmpAddress1, *tmpAddress2;
int result;
if( (tmpAddress1 = strchr(EmailAddress, '<')) && (tmpAddress2 = strchr(tmpAddress1, '>')) ) {
*tmpAddress2 = 0; // terminate the string temporarily.
result = snprintf(Buffer, MAIL_BUFFER_SIZE, FormatString , tmpAddress1+1);
*tmpAddress2 = '>'; // put it back the way it was.
return result;
}
return snprintf(Buffer, MAIL_BUFFER_SIZE , FormatString , EmailAddress );
} /* end FormatEmailAddress() */
Anybody that has ever attempted to send bracketed emails from a local Win machine is going to know right away what I'm talking about here. I'm guessing garretts is Garrett Serack, the open source software developer at Microsoft who's involved with the company's Open Source Technology Center. If so, Mr. Serack, I want to be the first to thank you. First one's on me if we ever meet!