SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sending email in php & another question...

    I'm writing a tell-a-friend script. A user can send the URL of the page he/she is on to a friend. They will fill out a form with their email and then their friend's email and send it. What would the code be that would send the url??

    Also how do I set up the so that it will send the email I have no idea how to do this...

    PHP Code:
    "From: $first_name $last_name",
           
    "To: $to",
           
    "Subject: Check out this site!" 
    I can do this much but how can I get it to actually send the email and appear from the address of the user ect. Do I need to use SMTP (I have no idea what that is)

    Anyway you can see I'm lost any guidence would be great!

  2. #2
    VICTORY IS MINE! luchazard's Avatar
    Join Date
    May 2001
    Location
    USA
    Posts
    229
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone??

    Basically I want to know the php code that will send form contents to another user!!

    Also how to make sure the URL they want to send can be put into a variable... like $URL

  3. #3
    SitePoint Enthusiast kcabobert's Avatar
    Join Date
    Aug 2001
    Location
    Topeka, KS
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay I think I understand what you are wanting. I have a multi purpose page I use to do various things like this.
    PHP Code:
    <?
    require("toptemplate.php");
    require(
    "funcs.php"); ?>
          <!-- Start Main Body here -->
          <?
    if(    $sendmail != "" ){
        if(
    $theirname!="" and $theiremail!="" and $messagebody!="" and vmail($theiremail)=="YES"){
            
    $emessage "$theirname ~ $theiremail \n \n They wrote: \n  $messagebody";
            
    mail("bobert@YourSite.com""Message from YourSite.com",
                  
    "$emessage \n\n\n I Collected the following information on $theirname: \n $userinf",
                    
    "From: YourSite.com <webmaster@YourSite.com>\nX-Mailer: PHP/" phpversion());

            
    mail("$theiremail""Your message to YourSite.com" ,
                  
    "You Wrote: \n $messagebody \n\n\n If your message requires a reply you should expect it within 24 hours. \n Thank you for using YourSite.com!",
                    
    "From: YourSite.com <webmaster@YourSite.com>\nX-Mailer: PHP/" phpversion());
            print(
    "<p>You should recieve an auto reply within a few minutes.</p> \n".
                    
    "<p>Click <a href='$returnto'>here</a> to return to the page you were on.</p> \n");
        } else {
            print(
    "<p>You did not fill out all required feilds, or you entered an invalid email address.</p> \n".
                    
    "<p>Click <a href='$PHP_SELF'>here</a> to return and try again.</p> \n".
                    
    "<p>Click <a href='$returnto'>here</a> to return to the page you were previously on.</p> \n");
        }
    } else {
        
    $returnto "$HTTP_REFERER";
        
    $userinf "The user was using: ".$HTTP_USER_AGENT."\n IP: ".$REMOTE_ADDR."\n They Came From: ".$returnto;
        print(
    "<p><FONT COLOR='#F80517'>All fields are required.</FONT></p>\n".
                
    "<form name='form1' method='post' action='$PHP_SELF'> \n".
                  
    "<table width='100%' border='0'> \n".
                    
    "<tr>  \n".
                      
    "<td width='150'>Your Name:</td> \n".
                      
    "<td>  \n".
                        
    "<input type='text' name='theirname' size='40' maxlength='40'> \n".
                      
    "</td> \n".
                    
    "</tr> \n".
                    
    "<tr>  \n".
                      
    "<td width='150'>Your Email:</td> \n".
                      
    "<td>  \n".
                        
    "<input type='text' name='theiremail' size='40' maxlength='40'> \n".
                      
    "</td> \n".
                    
    "</tr> \n".
                    
    "<tr>  \n".
                      
    "<td height='2' width='150'>Message:</td> \n".
                      
    "<td height='2'>&nbsp; </td> \n".
                    
    "</tr> \n".
                    
    "<tr> \n".
                      
    "<td width='150'>&nbsp;</td> \n".
                      
    "<td> \n".
                        
    "<textarea name='messagebody' cols='40' wrap='PHYSICAL' rows='20'></textarea> \n".
                      
    "</td> \n".
                    
    "</tr> \n".
                  
    "</table> \n".
                  
    "<p>&nbsp;</p> \n".
                  
    "<table width='100%' border='0'> \n".
                    
    "<tr> \n".
                      
    "<td width='10%'>&nbsp;</td> \n".
                      
    "<td width='45%'>  \n".
                        
    "<input type='submit' name='sendmail' value='Send'> \n".
                      
    "</td> \n".
                      
    "<td width='45%'>  \n".
                        
    "<div align='right'> \n".
                          
    "<input type='reset' name='Submit2' value='Reset'> \n".
                        
    "</div> \n".
                      
    "</td> \n".
                    
    "</tr> \n".
                  
    "</table> \n".
                  
    "<p>&nbsp; </p> \n".
                
    "<INPUT TYPE='hidden' name='returnto' value='$returnto'> \n".
                
    "<INPUT TYPE='hidden' name='userinf' value='$userinf'> \n".
                
    "</form> \n");
    }
    ?>

          <!-- End Main Body here -->
    <?require("bottemtemplate.php");?>
    Now I did not have time to clean that up or change it for you so you will have to do that. You will get an error running it unless you make a function called "vmail()" or delete that condition from the top iff statement. Again sorry I dont have time to explain it now but if you play with it it *should work out okay. Change all of the accourding domain names in the two "mail()" functions also. Good luck and I'll check back later to se if you have any questions.
    Microsoft's Motto: Resistance is futile, you will be assimilated.

    My dog's name is Jade; she is a Miniature pinscher.
    Click here to see some of her pictures


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
  •