Php mail header.

Discussion in 'PHP' started by Alice24, Aug 15, 2009.

  1. #1
    I have a problem when sending mail with php form.

    If the code it looks like this it works perfect:

    $headers .= 'From: Birthday Reminder <admin@eva.com> ' . "\r\n";

    but the problem is the email is not a variable ...

    if i try to put :


    $headers .= 'From: Birthday Reminder $email ' . "\r\n";
    where $email=$_POST['email']; in the mail it appears
    FROM: " <Birthday@yahoo.com>
    i have no ideea from where appears @yahoo.com
    i also tryed with $email=$_GET['email'] and $email=$_REQUEST['email']


    if i put:
    $headers .= 'From: Birthday Reminder <$frome> ' . "\r\n";
    in email it appers:
    FROM:Birthday Reminder <$frome@srv31.host.com>

    :|

    i just only want to appear
    From: Birthday Reminder $ email

    any ideea?
     
    Alice24, Aug 15, 2009 IP
  2. superdav42

    superdav42 Active Member

    Messages:
    125
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Looks like you just need to use double quotes. ie:
    $headers .= "From: Birthday Reminder $email " . "\r\n";
    Code (markup):
    instead of:
    $headers .= 'From: Birthday Reminder $email ' . "\r\n";
    Code (markup):
    Or just use the concat operator
    $headers .= 'From: Birthday Reminder ' . $email .  ' . "\r\n";
    Code (markup):
    Of course that depends of how the email looks when coming from the form. You might have to add the <>:
    $headers .= "From: Birthday Reminder <$email> " . "\r\n";
    Code (markup):
     
    superdav42, Aug 15, 2009 IP
  3. Alice24

    Alice24 Greenhorn

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Thank you. :)
    This one is perfect.
    
    $headers .= "From: Birthday Reminder <$email> " . "\r\n";
    
    PHP:
     
    Alice24, Aug 15, 2009 IP
  4. Alice24

    Alice24 Greenhorn

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #4
    one more Q.
    don't want to start another topic.
    after the mail is send i have the echo "Mail send $to";
    but if i refresh the page the mail is send again... every time i refresh..
    i also have set
    if (isset($_POST['Send'])) {

    // Mail it
    mail( $to, $subject, $message, $headers);

    echo "Mail send to $to ";
    }
     
    Alice24, Aug 15, 2009 IP