www.webdeveloper.com
Results 1 to 3 of 3

Thread: MAIL command - Is this structure OK?

  1. #1
    Join Date
    Feb 2003
    Posts
    102

    MAIL command - Is this structure OK?

    Hi there,

    I currently have a Flash form that uses a PHP script to do the sending. The sample PHP form I based this on (which works) looked like this:

    Code:
    <?
     
       $to = "you@yourdomain.com";
       $msg = "$name\n\n";
       $msg .= "$message\n\n";
    
      mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");
    
    ?>
    Bar a couple of mods to the Flash File (extra fields added), my PHP code looks like this:

    Code:
    <?
     
       $to = "csjacks@hotmail.com";
       $msg = "$name\n\n";
       $msg .= "$company\n\n";
       $msg .= "$phone\n\n";
       $msg .= "$fax\n\n";
       $msg .= "$mobile\n\n";
       $msg .= "$email\n\n";
       $msg .= "$notes\n\n";
    
    
      mail($to, "Website Interest - Devt Project Opps", $msg, "From: Gazco Website\nReply-To: $email\n");
    
    ?>

    Can someone tell is there is something immediately wrong with the way I've structured the MAIL command in my example?

    You can see the site working HERE. (Click Development Project Opportunities to see the form).

    Any help is very much appreciated!

    Cheers,

    Chris

  2. #2
    Join Date
    Feb 2005
    Location
    Tauranga
    Posts
    2,062
    I do some thing like this ( No error checking on this one ).

    I try set everything before i put put the mail() just for cleanly -ness and make sure the message content is hard left so it inserts no whitespace in to the mail content, making it look yuck in the mail browser.

    PHP Code:
    <?php

    $name    
    $_POST['field_name'];
    $email   $_POST['field_email'];
    $phone   $_POST['field_phone'];
    $company $_POST['field_company'];
    $subject $_POST['field_subject'];
    $content $_POST['field_content'];

    $sender  "info@gozipline.com"
    $headers "From: $email\n".
               
    "Reply-to: $email\n".
               
    "BCC: sheldon@gozipline.com\n";
    $date    date("r");
    $message "
    You have received a support request from 
    $name,\n
    Email   : 
    $email\n
    Phone   : 
    $phone\n
    Company : 
    $company\n
    \n
    $content\n\n\n
    $date\n\n
    ___________________________________________________________________\n\n 
    Zipline Interactive                        http://www.gozipline.com\n\n"



    $message wordwrap($message70);

    mail($sender$subject$message$headers);
    $_SESSION['message']['type'] = "Success";
    $_SESSION['message']['content'] = "Your Support request was sent, A Zipline representative will contact you shortly.";
    header("Location: ../index.php?page=support");    

    ?>

  3. #3
    Join Date
    Feb 2003
    Posts
    102
    Cheers for that Sheldon!!!

    Sorry for the delayed reply - have been away from my PC for one brilliant week!

    That looks like a nice bit of code, nice and clear! Unfortunately it didn't work as expected. Here's my modified version of the code:

    Code:
    <?php 
    
    $name    = $_POST['field_name']; 
    $email   = $_POST['field_email']; 
    $phone   = $_POST['field_phone']; 
    $subject = $_POST['field_subject']; 
    $content = $_POST['field_content']; 
    
    $sender  = "csjacks@hotmail.com"; 
    $headers = "From: $email\n". 
               "Reply-to: $email\n". 
               "BCC: chris@artboxgraphics.com.au\n";
    $date    = date("r"); 
    $message = " 
    You have received a support request from $name,\n 
    Email   : $email\n 
    Phone   : $phone\n 
    \n 
    $content\n\n\n 
    $date\n\n 
    ___________________________________________________________________\n\n 
    Beam Marine Optics                  http://www.beammarineoptics.com\n\n"; 
    
    
    $message = wordwrap($message, 70); 
    
    mail($sender, $subject, $message, $headers); 
    
    ?>
    The results I get in my email are as follows:

    Code:
    From :  <TEXTFORMAT LEADING=\"2\"> 
    Reply-To :  <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"14\" COLOR=\"#4040FF\" LETTERSPACING=\"0\" KERNING=\"0\">chris@artboxgraphics.com.au</FONT></P></TEXTFORMAT> 
    Sent :  Tuesday, 28 August 2007 9:34:52 AM 
    To :  csjacks@hotmail.com 
    Subject :  BMO Website Submission 
      
      |  |  | Inbox 
     
     
    You have received a support request from <TEXTFORMAT LEADING=\"2\"><P
    ALIGN=\"LEFT\"><FONT FACE=\"Arial\" SIZE=\"14\" COLOR=\"#4040FF\"
    LETTERSPACING=\"0\" KERNING=\"0\">Chris
    Jacks</FONT></P></TEXTFORMAT>,
     
    Email   : <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT
    FACE=\"Arial\" SIZE=\"14\" COLOR=\"#4040FF\" LETTERSPACING=\"0\"
    KERNING=\"0\">chris@artboxgraphics.com.au</FONT></P></TEXTFORMAT>
     
    Phone   : <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT
    FACE=\"Arial\" SIZE=\"14\" COLOR=\"#4040FF\" LETTERSPACING=\"0\"
    KERNING=\"0\">0402823258</FONT></P></TEXTFORMAT>
     
    
     
    <TEXTFORMAT LEADING=\"2\"><P ALIGN=\"LEFT\"><FONT FACE=\"Arial\"
    SIZE=\"14\" COLOR=\"#4040FF\" LETTERSPACING=\"0\" KERNING=\"0\">My
    message goes in here.</FONT></P></TEXTFORMAT>
    
    
     
    Mon, 27 Aug 2007 18:34:52 -0500
    
     
    ___________________________________________________________________
    
     
    Beam Marine Optics                  http://www.beammarineoptics.com

    The code on my Button in Flash 8 is:

    Code:
    on (release) {
    	if (field_name eq "" or field_email eq "" or field_phone eq "" or field_content eq "") {
    		stop();
    	} else {
    		loadVariablesNum("beamform.php", 0, "POST");
    		gotoAndPlay(2);
    	}
    }
    Any ideas as to where I might be going wrong?

    Note: The subject of my email is also hardwired in the Flash doc with:
    Code:
    field_subject = "BMO Website Submission";
    ...just in case you were wondering where that came from!


    Thanks again!


    Cheers,

    Chris
    Last edited by Chris Jacks; 08-27-2007 at 11:39 PM. Reason: typo

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles