Web Analytics Made Easy -
StatCounter mailing question - CodingForum

Announcement

Collapse
No announcement yet.

mailing question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • mailing question

    Hello,

    I have a page that a user fills out to send an email to the address of his choice, my only problem is that its written "Nobody" (see attachment) instead of whats written in the from textbox.

    anyway, maybe with my code, itll be more clear

    this is where they fill it out

    PHP Code:

    <table width="410" height="191" border="0" cellpadding="0" cellspacing="0">
      <tr> 
        <td width="470" height="191" align="left" valign="top"> 
          <form action="emailscript.php" method="post" enctype="multipart/form-data" name="emailfriend" id="emailfriend"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="130" height="19" align="left" valign="top" class="normal">Your 
                  name </td>
                <td width="280">
    <input name="from" type="text" class="textfield" id="from"></td>
              </tr>
              <tr> 
                <td width="130" align="left" valign="top" class="normal">Your email</td>
                <td width="280">
    <input name="fromemail" type="text" class="textfield" id="fromemail"></td>
              </tr>
              <tr> 
                <td width="130" align="left" valign="top" class="normal">Friends name</td>
                <td width="280">
    <input name="to" type="text" class="textfield" id="to"></td>
              </tr>
              <tr> 
                <td width="130" height="19" align="left" valign="top" class="normal">Friends 
                  email</td>
                <td width="280" height="19">
    <input name="toemail" type="text" class="textfield" id="toemail"></td>
              </tr>
              <tr> 
                <td width="130" align="left" valign="top" class="normal">subject</td>
                <td width="280">
    <input name="subject" type="text" class="textfield" id="subject"></td>
              </tr>
              <tr> 
                <td width="130" align="left" valign="top" class="normal"> 
                  <p>additional comments
                  <p> </td>
                <td width="280">
    <textarea name="comments" cols="400" rows="5" wrap="VIRTUAL" class="textfield" id="textarea"></textarea>
                  <br>
                  <input type="text" name="referer" value="<?php echo $_SERVER['HTTP_REFERER'?>"> 
                  <input name="Submit" type="submit" class="button" value="Submit"></td>
              </tr>
            </table> 
            </form>
    and this is my script

    PHP Code:

      $from 
    trim($_POST['from']); 
      
    $fromemail 'From: '.trim($_POST['fromemail']); 
      
    $fromemail 'Content-Type: text/html; charset=iso-8859-15';
      
    $to trim($_POST['to']); 
      
    $toemail trim($_POST['toemail']); 
      
    $subject trim($_POST['subject']); 
      
    $comments trim($_POST['comments']); 
      
    $referer trim($_POST['referer']); 

      
    $mailcontent "Hey $to, \n$from went to <a href=\"http://www.mtl-baseline.com\">[url]www.mtl-baseline.com[/url]</a> and found and interesting thing that he would like for you to check out. Here is the link: <a href=\"$referer\">$referer</a> 
                      \nadditional comments by 
    $from$comments"
                    
      
    mail($toemail$subject$mailcontent$to); 
    i am sure im forgetting one stupid thing.......

  • #2
    I'm not sure I understand your problem.

    I took your code and ran it and it worked almost fine. I just had to make sure I escaped all the quotes you left unescaped, and it ran perfectly.

    I also had to edit my php.ini file since i hadn't setup the smtp server (and I'm not running one on my localhost).

    So I'm not sure what your trouble is. All you have to do is escape the quotes and setup your php.ini and it should work for you.

    PHP Code:
    $from trim($_POST['from']); 
    $fromemail 'From: '.trim($_POST['fromemail']); 
    $fromemail 'Content-Type: text/html; charset=iso-8859-15';
    $to trim($_POST['to']); 
    $toemail trim($_POST['toemail']); 
    $subject trim($_POST['subject']); 
    $comments trim($_POST['comments']); 
    $referer trim($_POST['referer']); 

    $mailcontent "Hey $to, \n$from went to <a href=\"http://www.mtl-baseline.com\"><a href=\"http://www.mtl-baseline.com\" target=\"_blank\">[url]www.mtl-baseline.com[/url]</a></a> and found and interesting thing that he would like for you to check out. Here is the link: <a href=\"$referer\">$referer</a>"
                     
    "\nadditional comments by $from$comments"
                    
      
    mail($toemail$subject$mailcontent$to); 
    Let me know if you have any further troubles,
    Sadiq.

    Comment


    • #3
      here's the link, ill prove it....

      http://www.mtl-baseline.com/establishment.php?name=Club%20Crescent

      click on "email to a friend"

      fill out the fields (obviously put your email in both the 2nd and 4th text box)......the whole page is still raw so forget the aestetics.....anyway..try it out...cuz i get the problem

      Comment


      • #4
        Hah!

        What the heck? Where did it even get that email address from?
        Nobody <[email protected]>

        Are you using them for your smtp server? There could be some issues there... otherwise I have no idea. Because the script worked fine on my computer, so it's not the script. It's got something to do with your configurations.

        Good luck with it,
        Sadiq.

        Comment


        • #5
          Your mail function is set up wrong.
          PHP Code:
          $to trim($_POST['to']); 
          // snip

          mail($toemail$subject$mailcontent$to); 
          It should be

          PHP Code:
          $fromheaders "From: "$_POST['from'] ." <".$_POST['fromemail'].">";
          mail($toemail$subject$mailcontent$fromheaders); 

          Comment


          • #6
            thanx nightfire, that works great

            Comment

            Working...
            X