Emailing user information problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidPr
    New Member
    • Mar 2007
    • 155

    Emailing user information problem

    I want to email the results of a form to the user. Everything is being emailed except for $company, $address, $city, $state and $zip.

    I'm obviously not working the ." correctly. How is the proper way of doing this? Thanks.

    [PHP] function sendWelcome($us er, $email, $pass){
    $from = "From: ".EMAIL_FROM_NA ME." <".EMAIL_FROM_A DDR.">";
    $subject = "website - Welcome!";
    $body = $user.",\n\n"
    ."Welcome! You've just registered! "
    ."with the following information:\n\ n"
    ."Username: ".$user."\n "
    ."Password: ".$pass."\n \n"
    ."".$company."\ n"
    ."".$address."\ n"
    ."".$city.", ".$state." ".$zip."\n\ n"

    ."If you ever lose or forget your password, a new "
    ."password will be generated for you and sent to this "
    ."email address, if you would like to change your "
    ."email address you can do so by going to the "
    ."My Account page after signing in.\n\n"
    ."- admin";

    return mail($email,$su bject,$body,$fr om);
    }[/PHP]
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, David.

    You'll probably find that it's easier to maintain just to do this:

    [code=php]$body = <<<EBODY
    {$user},

    Welcome! You've just registered with the following information:

    Username: {$user}
    Password: {$pass}

    {$company}
    {$address}
    {$city}, {$state} {$zip}

    If you ever lose or forget your password, a new password will be generated for you and sent to this email address, if you would like to change your email address you can do so by going to the My Account page after signing in.

    - admin
    EBODY;[/code]

    I like to enclose my variables within curly braces when using heredoc syntax, but it is not strictly necessary.

    Comment

    • DavidPr
      New Member
      • Mar 2007
      • 155

      #3
      Thanks, it certainly looks easier.

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        One thing to note about that is that you don't have any control over special characters such as \r and \n.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Are you getting blank values where the company name, address, etc. should go? Your function only takes the Username, email address and password as arguments. Is this intentional?

          Comment

          Working...