Computing.Net > Forums > Web Development > Php send mail code problem

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Php send mail code problem

Reply to Message Icon

Name: ian_ok
Date: September 17, 2009 at 07:41:30 Pacific
OS: Windows XP
Product: Capcom Street fighter iv (ps3)
Subcategory: PHP
Comment:

I have the current code, but have just found out that is doesn't allow certain email addresses to work:

elseif (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from))

So if I have an email of:
mynamehere-@domain.com

It would fail, can anyone advise which part of the code I should change.

Thanks Ian

Venta Sanlucar



Sponsored Link
Ads by Google

Response Number 1
Name: Radix-64
Date: September 18, 2009 at 16:33:16 Pacific
Reply:

Hi, are you trying to validate the email address? I prefer using eregi function.

Perhaps try using preg_match with this regular expression:

/^[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)*\@[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+(?:\.[^\x00-\x20()<>@,;:\".[\]\x7f-\xff]+)+$/i

or

/^[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+)*@[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+(\.[a-zA-Z0-9\!\#\$\%\&'\*\+\-\/=\?\^\_\`\{\|\}\~]+)*$/


0

Response Number 2
Name: ian_ok
Date: September 27, 2009 at 09:16:59 Pacific
Reply:

I've worked it out, by deleting part of the code:

elseif (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $from))

By deleting the part in BOLD

Venta Sanlucar


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Php send mail code problem

cant send mail from localhost www.computing.net/answers/webdevel/cant-send-mail-from-localhost/3788.html

PHP mail() vs PHP PEAR:mail www.computing.net/answers/webdevel/php-mail-vs-php-pearmail/3456.html

PHP e-mail form: Option element www.computing.net/answers/webdevel/php-email-form-option-element/3147.html