Blank behind dot disappears with mail()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nik Futter

    Blank behind dot disappears with mail()

    I have a strange effect:

    From a formula I transfer firstname, lastname and email address to a PHP
    script. Then mail() shall send this data.

    $mailheaders = "From: ".$_POST['firstname']." ".$_POST['lastname'].
    "<".$_POST['email'].">\n";
    $mailheaders .= "Reply-To: ".$_POST['email'];
    mail($_SESSION['recipient'], $_SESSION['subject'], $body, $mailheaders);

    Most times this works quite well: A blank is "usually" between first name
    and last name. But: If the first name is abbreviated with a point, then the
    blank is suppressed in the sent mail.

    Correct:
    Firstname: Nik
    Lastname: Futter
    EMail: eMail
    changes to: Nik Futter <eMail>

    But:
    Firstname: N.
    Lastname: Futter
    EMail: eMail
    changes to N.Futter <eMail>

    Or (extreme example)
    Firstname: F G
    Lastname: Xtra Zeta
    changes to: F G Xtra Zeta

    Firstname: F. G.
    Lastname: Xtra. Zeta
    changes to: F.G.Xtra.Zeta

    For checking I also have attached the variable $mailheaders to the body of
    the sent email. At this stage the blank exist behind the dot.

    Why this happens ? Is it an error in the script or in mail() ?


  • CountScubula

    #2
    Re: Blank behind dot disappears with mail()

    "Nik Futter" <spam@unawave.d e> wrote in message
    news:btchad$h6k $1@online.de...[color=blue]
    > I have a strange effect:
    >
    > From a formula I transfer firstname, lastname and email address to a PHP
    > script. Then mail() shall send this data.
    >
    > $mailheaders = "From: ".$_POST['firstname']." ".$_POST['lastname'].
    > "<".$_POST['email'].">\n";[/color]

    change to:
    $mailheaders = "From: \"{$_POST['firstname']} {$_POST['lastname']}\" " .
    "<{$_POST['email']}>\n";

    I did two things here, the first, was not a problem, just makes it easier to
    read, and that is use {} around the variable inside a quoted string, insead
    of string: . variable . string

    ok, now the second part, might be your problem, I added \" around the name
    the resulting from may need quotes in it, so it looks like this:

    from: "john doe" <jdoe@mydom.com >

    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools


    Comment

    • Nik Futter

      #3
      Re: Blank behind dot disappears with mail()

      > ok, now the second part, might be your problem, I added \" around the name[color=blue]
      > the resulting from may need quotes in it, so it looks like this:
      >
      > from: "john doe" <jdoe@mydom.com >[/color]

      Thank you very much - this works fine !

      Nik


      Comment

      Working...