+ Reply to Thread
Results 1 to 7 of 7

Thread: from header?

  1. #1
    focus is offline x10 Sophmore focus is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    112

    from header?

    I'm having trouble with the from header in the below mail script. Can anyone help?

    PHP Code:
    function is_valid_email($from_email)
    {
        return 
    preg_match('#^[a-z0-9.!\#$%&\'*+-/=?^_`{|}~]+@([0-9.]+|([^\s\'"<>]+\.+[a-z]{2,6}))$#si'$from_email);



    $headers  =  "From: " $_POST["name"];
    $headers .= "<" $_POST["email"] . ">\r\n";
    $headers .= "Reply-To: " $_POST["email"] . "\r\n";

    $headers .=     "MIME-Version: 1.0\r\n"
          
    "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
        
    "Content-Transfer-Encoding: 7bit\r\n"


    $to_email "dada@hotmail.com";
    $subject "Watch Website Thing";
    $name.=$_POST['name']."\n" ;
    $from_email.=$_POST['email'] ."\n" ;
    $msg.=$_POST['message']."\n" ;


    $message "

    <body>

        <b>Name:</b><br>
        
    $name

    <br> <br>

        <b>Email:</b><br>
        
    $from_email

    <br> <br>

        <b>Message:</b><br>
        
    $msg

    </body>
    "
    ;
        
        
    $sent mail($to_email$subject$message$headers) ;
    if(
    $sent)
    {print 
    "Your mail was sent successfully."; }

    else
    {print 
    "We encountered an error sending your mail"; }

    ?> 

  2. #2
    dlukin is offline x10 Lieutenant dlukin is on a distinguished road
    Join Date
    Oct 2009
    Posts
    427

    Re: from header?

    PHP Code:

        
        
    $sent 
    mail($to_email$subject$message$headers) ;
    if(
    $sent)
    {print 
    "Your mail was sent successfully."; }

    else
    {print 
    "We encountered an error sending your mail"; }


    print 
    "\$_POST['email'] is " $_POST["email"
    print 
    "<code>$headers</code>";


    ?> 
    Add the last two lines to see what the actual values are.
    ...you might have to look at the return source since you put from address in < brackets >
    Last edited by dlukin; 08-08-2010 at 12:10 PM.

  3. #3
    focus is offline x10 Sophmore focus is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    112

    Re: from header?

    the
    PHP Code:
    print "<code>$headers</code>"
    bit did not work but when that is removed it displays Your mail was sent successfully.$_POST['email'] is focus@hotmail.com

  4. #4
    Qombat's Avatar
    Qombat is offline x10Hosting Member Qombat is an unknown quantity at this point
    Join Date
    Aug 2010
    Posts
    25

    Re: from header?

    Any particular reason why your from headers are in "<" and ">"?
    Elliot Speck | Unofficial Technical and Systems Support
    Filemaw - Free file sharing for the masses!

  5. #5
    focus is offline x10 Sophmore focus is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    112

    Re: from header?

    No reason jus tryin to figure it out following different tutorials but i cant seem to (

  6. #6
    focus is offline x10 Sophmore focus is an unknown quantity at this point
    Join Date
    Feb 2008
    Posts
    112

    Re: from header?

    I got it working abit better but i can only get it working to display the email its from when the email is sent. I would like it to display the name and then when the user presses reply it replies to their email. (I hope that made sense)

    My code at the moment:

    PHP Code:
    $headers .=     "MIME-Version: 1.0\r\n"
          
    "Content-Type: text/html; charset=\"iso-8859-1\"\r\n"
        
    "Content-Transfer-Encoding: 7bit\r\n"


    $to_email "daaaa@hotmail.com";
    $subject "Watch Fair";
    $name.=$_POST['name']."\n" ;
    $from_email.=$_POST['email'] ."\n" ;

    $headers .= "From: $from_email\r\n";

        
    $msg .=$_POST['message']."\n" ;


        
    $message "

    <body>

        <b>Name:</b><br>
        
    $name

    <br> <br>

        <b>Email:</b><br>
        
    $from_email

    <br> <br>

        <b>Message:</b><br>
        
    $msg

    </body>
    "
    ;


        
    $sent mail($to_email$subject$message$headers) ; 

  7. #7
    bhupendra2895's Avatar
    bhupendra2895 is offline x10 Elder bhupendra2895 is an unknown quantity at this point
    Join Date
    Jun 2010
    Location
    India
    Posts
    554

    Re: from header?

    Hi, I don't know why your from header is not working.But to help you I have copied and pasted this from header from one of the mail in my inbox.
    From: Example College Team <mail- noreply@example.com>
    Hope this will help you.
    Liked this? Click on the icon on the bottom of post to make me .

+ Reply to Thread

Similar Threads

  1. Using header
    By menglim in forum Programming Help
    Replies: 3
    Last Post: 03-09-2010, 09:58 AM
  2. Header please!
    By Gaming To The Extreme in forum The Marketplace
    Replies: 3
    Last Post: 03-23-2008, 12:24 PM
  3. Header already sent.
    By oracle in forum Free Hosting
    Replies: 7
    Last Post: 11-21-2007, 11:17 PM
  4. Header
    By Reesey in forum Free Hosting
    Replies: 25
    Last Post: 09-12-2007, 02:03 PM
  5. Header [REQ]
    By James in forum The Marketplace
    Replies: 7
    Last Post: 04-13-2006, 06:03 PM

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