SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP sendmail addresses

    Hi

    I am fairly new to using sendmail in a PHP script. Currently in order to send an email I use:

    mail($email, $subject, $message, "From: me@domain.com");

    which works fine except that when looking at the resulting email the from line just has that email address listed as me@domain.com. What I really want is:

    "Guy" <me@domain.com>

    So that Guy shows as the alias for the email address.

    Can anyone tell me exactly how I should amend the code above?

    Thanks

    Guy

  2. #2
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    $headers = "";
    $headers .= "From: Guy <me@domain.com> \r\n";
    mail($email, $subject, $message, $headers);
    http://in.php.net/manual/en/function.mail.php
    Anjanesh

  3. #3
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Southwest US
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try using:
    PHP Code:
    mail($email$subject$message"From: \"Guy\"  me@domain.com"); 
    Hope this helps,
    Itshim

  4. #4
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Itshim quotes("") may not be required but <> is defintely required.
    "From: Guy <me@domain.com>"
    Anjanesh

  5. #5
    SitePoint Addict
    Join Date
    Oct 2004
    Location
    Southwest US
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, my mistake...
    Shouldn't this work?
    PHP Code:
    mail($email$subject$message"From: \"Guy\"  <me@domain.com>"); 

  6. #6
    SitePoint Evangelist anjanesh's Avatar
    Join Date
    Jun 2004
    Location
    Mumbai
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually this should work now - after this is the format we input in Yahoo mail, OE and Thunderbird Email Clients.
    But if you look at the mail function, you'll find that quotes are never shown - though its there in the RFC
    Anjanesh

  7. #7
    SitePoint Member
    Join Date
    May 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - I'll try this.

    Guy


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •