Mail Header check

freecrm

New Member
Messages
629
Reaction score
0
Points
0
This may be a very daft question, but it appears as though some of the people wanting to register on my site (www.freecrm.x10hosting.com) are not validating their application.

On submitting initial info, it sends (php mail) info to the e-mail submitted in the form.

On checking my failed mail, I get a "malformed recipient address".

A message that you sent contained one or more recipient addresses that were
incorrectly constructed:

<>: missing or malformed local part

This could be down to 2 things - either browsers are delibertaely putting in a false e-mail address (which should have been verified on the registration page!) or my code is duff.

Could someone have a quick look over this to see if I've got something horribly wrong?
PHP:
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $headers .= "Content-Transfer-Encoding: 7bit\r\n"; 
   $headers .= 'From: CRM Administrator <webmaster@freecrm.x10hosting.com>' . "\r\n";
   $headers .= 'Reply-To: webmaster@freecrm.x10hosting.com' . "\r\n";
   $headers .= 'X-Mailers: PHP /'.phpversion() . "\r\n";
   $subject = "CRM, The Free Solution : Account Verification";
  
   $message  = 'message content.. blah de blah';
  
  ini_set(sendmail_from,'webmaster@freecrm.x10hosting.com');//to correct from bug
 
  if (@mail(''.$firstname.' '.$lastname.'<'.$contactemail.'>',stripslashes($subject),stripslashes($message),stripslashes($headers)))
  {
    echo ('
 <p>Verification e-mail successfully sent to '. $contactemail . '</p>
 ');
  }
  else
  {
    echo ('
 <p>Error! The verification e-mail has failed to send to ' . $contactemail . '. Please try again.</p>
 ');
  }

Variables:

$firstname - just a posted text value
$lastname - another posted text value
$contactemail - the submitted e-mail address

I've checked and checked this and it works fine in gmail, but something must be wrong.

Any ideas?
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
I doubt this is it, but it may be worth a try:

from php.net:

Note: If messages are not received, try using a LF (\n) only. Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822.

Also, since you're already setting headers, why don't you specify the "Return-path:" header directly, instead of using ini_set?
 

dickey

New Member
Messages
128
Reaction score
0
Points
0
This I got to know if you resolved I've been wanting to ask a similar question but couldn't piece out a meaningful question. So if anyone knows how to resolve this. please help.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
<>: missing or malformed local part

The mailer is probably having problems parsing the mailbox. Try putting double quotes around the name and make sure there's a space before the '<' as such: "First Last" <user@domain.tld>

PHP:
   $headers .= 'From: CRM Administrator <webmaster@freecrm.x10hosting.com>' . "\r\n";
 ...
  if (@mail(''.$firstname.' '.$lastname.'<'.$contactemail.'>',stripslashes($subject),stripslashes($message),stripslashes($headers)))
  {
Try instead:
PHP:
   $headers .= 'From: "CRM Administrator" <webmaster@freecrm.x10hosting.com>' . "\n";
 ...
  if (@mail('"'.$firstname.' '.$lastname.'" <'.$contactemail.'>',stripslashes($subject),stripslashes($message),stripslashes($headers)))
  {
Also, check the exact $to string you're feeding to mail(). Perhaps there are some extra characters that are throwing off the MTAs.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
If you read the actual standards document ( http://www.faqs.org/rfcs/rfc2822 ) you will see that the display name can be any "phrase" and it has no real bearing, so I don't think quoting it will make a difference It also says there can be any character before the angle brackets including \r\n. The only thing that could cause a problem is using characters that have special meaning to the mailer i.e. angle brackets
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
This is really random but nice website freecrm

Thanks - its taken a while!

If messages are not received, try using a LF (\n) only

I had tried this before but hadn't tested it thoroughly. I think what I'll do is try small sections at a time to eliminate all posibilities.

Also, since you're already setting headers, why don't you specify the "Return-path:" header directly, instead of using ini_set?

I understand that there is a php bug with From headers, which the ini-set apparently solves. I also heard that the Return-Path doesn't work correctly - have I been misled?

Try putting double quotes around the name and make sure there's a space before the '<' as such: "First Last" <user@domain.tld>

Done - but I can't get a through test on my own. If anyone has the inclination, it would be good if you could try it?

Also, check the exact $to string you're feeding to mail().

Checked - no problems. The text field is validated using JS for formatting and the data is passed very simply to this page.

I'll keep you updated if this has solved the problem.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
It worked for me no problem. Feel free to delete my account (garrettroyce) :)

Very very nice site by the way.

Maybe a good starting point would be to catch the errors from the mail function and have all of the variables stored in a log.
 
Last edited:

freecrm

New Member
Messages
629
Reaction score
0
Points
0
It worked for me no problem. Feel free to delete my account (garrettroyce) :)

Very very nice site by the way.

Maybe a good starting point would be to catch the errors from the mail function and have all of the variables stored in a log.

Many thanks for your kind words!:biggrin:

Your registration seems to have worked fine so I'm pleased with the result. I have deleted your record as requested.

I like the idea of the log. My current log only stores IP's and the like, but a form/ error log would solve any problems (if it re-occurs!).

I have tried several more e-mail servers/accounts and some are blocked due to blacklisting (cossacks@x10...) so I can't do a lot about that.

The more tests I can get, the better!
 
Top