Ticket #1485857 (closed Feature Requests: fixed)

Opened 10 months ago

Last modified 4 months ago

Check E-Mail Addresses

Reported by: lacri Owned by:
Priority: 5 Milestone: 0.3.1
Component: Core functionality Version: 0.2.2
Severity: normal Keywords: E-Mail Check
Cc: suporte@…, patrickvw

Description

It would be beautiful if before the dispatch of emails or also with add an email address into the addressbook one would check whether the email address is valid.

Thus avoidable errors in the log would be avoided.

Failed to add recipient 'support@xstreetsl.com.' in /var/www/htdocs/roundcube/program/steps/mail/func.inc on line 1409

I think that would be a very meaningful feature

check via javascript or php ...

function validate_email_mx($email)
	{
  if(eregi("^[0-9a-z_]([-_.']?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,4}$",$email,$check))
  	{
    if(getmxrr(substr(strstr($check[0], '@'), 1),$validate_email_temp))
    	{
      return TRUE;
      }
    if(checkdnsrr(substr(strstr($check[0], '@'), 1),"ANY"))
    	{
      return TRUE;
      }
    }
  return FALSE;
  }
function mailcheck(str){
var gesamtemail=/^(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
var vordemat=/^(\w+(?:\.\w+)*)$/i
var domain=/^@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (gesamtemail.test(str)) {
return true
}else{
if (domain.test(str)) {
return true
}else{
if (vordemat.test(str)) {
return true
}else{
return false
}
}
}
}

Attachments

email_check.patch (4.6 KB) - added by alec 6 months ago.

Change History

Changed 7 months ago by netbit

  • cc suporte@… added

Note: getmxrr() should not be used for the purposes of address verification. Only the mailexchangers found in DNS are returned, however, according to RFC 2821 (http://www.ietf.org/rfc/rfc2821.txt) when no mail exchangers are listed, hostname itself should be used as the only mail exchanger with a priority of 0.

getmxrr() and checkdnsrr() also work under windows platforms only after PHP 5.3.0

Changed 6 months ago by alec

Changed 6 months ago by alec

I've add a patch, but I'm not sure about the performance of dns checks. So, maybe this should be optional. From the other side, it's better to check addresses before the whole message structure is created/joined (with attachments etc.) into memory. Another thought, the check probably shouldn't be called for draft save action. BTW. we've got already a function for e-mail checking in javascript.

Changed 6 months ago by lacri

works fine !!

Changed 5 months ago by alec

  • status changed from new to closed
  • resolution set to fixed

Implemented in r3042

Changed 4 months ago by patrickvw

  • cc patrickvw added
  • status changed from closed to reopened
  • resolution fixed deleted

Actually, the provided patch fails to validate email addresses that use IDN. user@宫殿.com fails validation, although the address is perfectly valid.

I guess the best way would be to test for the presence of non-ascii characters and translate it to punycode before doing the DNS lookup.

I cannot provide patch right now, but I would suggest looking at the PEAR Validate::email function at http://pear.php.net/package/Validate for a way to achieve this

It may be useful also to use a PEAR library function than reinventing the wheel inside RoundCubemail?. But this is a designer choice.

Changed 4 months ago by alec

  • status changed from reopened to closed
  • resolution set to fixed

The whole Roundcube is not working with IDN addresses, so I think we don't need to reopen this bug. See #1483894.

Note: See TracTickets for help on using tickets.