+ Reply to Thread
Results 1 to 9 of 9

Thread: Mail Header check

  1. #1
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Mail Header check

    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 Code:

       
       $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?

  2. #2
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Mail Header check

    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?
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  3. #3
    dickey's Avatar
    dickey is offline x10 Sophmore dickey is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    128

    Re: Mail Header check

    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.
    Don't get me wrong as I believe if and when I help someone I also help myself whereby whatever someone learns I also learn.

    But I will also accept credits or reps if you really want to part with it.

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Mail Header check

    Quote Originally Posted by freecrm View Post
    <>: 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>

    Quote Originally Posted by freecrm View Post
    PHP Code:
       $headers .= 'From: CRM Administrator <webmaster@freecrm.x10hosting.com>' "\r\n";
     ...
      if (@
    mail(''.$firstname.' '.$lastname.'<'.$contactemail.'>',stripslashes($subject),stripslashes($message),stripslashes($headers)))
      { 
    Try instead:
    PHP Code:
       $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.

  5. #5
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Mail Header check

    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
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  6. #6
    dsage152's Avatar
    dsage152 is offline x10Hosting Member dsage152 is an unknown quantity at this point
    Join Date
    Mar 2009
    Location
    Glen Ellyn, Illinois, United States
    Posts
    11

    Re: Mail Header check

    This is really random but nice website freecrm
    Leadership is the art of getting someone else to do something you want done because he wants to do it. - Dwight D. Eisenhower

    No good decision was ever made in a swivel chair. - George S. Patton

  7. #7
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Mail Header check

    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.

  8. #8
    garrettroyce's Avatar
    garrettroyce is offline Generally Helpful Member garrettroyce is a glorious beacon of lightgarrettroyce is a glorious beacon of light
    Join Date
    Apr 2008
    Location
    IL, USA
    Posts
    3,746

    Re: Mail Header check

    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 by garrettroyce; 04-22-2009 at 05:39 PM.
    gjr.gr - coming soon: secrets of OCD coding from a self taught tinkerer

  9. #9
    freecrm's Avatar
    freecrm is offline x10 Elder freecrm is an unknown quantity at this point
    Join Date
    May 2008
    Location
    UK
    Posts
    629

    Re: Mail Header check

    Quote Originally Posted by garrettroyce View Post
    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!

    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!

+ Reply to Thread

Similar Threads

  1. Replies: 9
    Last Post: 08-11-2011, 05:58 AM
  2. Not receiving mail
    By hypochondriac in forum Free Hosting
    Replies: 0
    Last Post: 03-15-2008, 09:14 AM
  3. imap issues on windows mail... cannot send email
    By enever in forum Free Hosting
    Replies: 6
    Last Post: 03-04-2008, 03:34 PM
  4. Mail account seems to have been changed?
    By KizoziK in forum Free Hosting
    Replies: 1
    Last Post: 10-30-2007, 11:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers