Jump to content


Photo

Mailing Forms


  • Please log in to reply
4 replies to this topic

#1 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 September 2006 - 01:25 AM

Yeah, yeah you probably were asked plenty of times but I still can't figure it out. Right now I'm using a mailing server to send me form data but how could I have it emailed to me by using just php?

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 25 September 2006 - 01:31 AM

Plan A: read the manual -> http://ca.php.net/ma...en/ref.mail.php

Plan B: search these forums for mail()

Either/both will show you how to.
Legend has it that reading the manual never killed anyone.
My site

#3 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 September 2006 - 01:33 AM

Okay thanks and also wanted to know (totally OT but..) how do you make each post so you have a signature attached to the bottom?

#4 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 September 2006 - 01:52 AM

Okay so all I have to do is add this to my script?
<?php

$hostname = 'maildomain.net';

// path to smtp.php file from XPM2 package for inclusion
require_once '/path/smtp.php';

$mail = new SMTP;
$mail->Delivery('client');

$mail->From('me@'.$hostname, 'My name');
$mail->FromHost($hostname, $havemx);
if(!$havemx) die("The hostname: '".$hostname."' doesn't have a valid MX zone!");

$mail->AddTo('client@destination.net');
$mail->Text('It is simple to use XPM2');
$sent = $mail->Send('Hello World!');

echo $sent ? 'Success.' : $mail->result;

?>
God, this makes like no sense to me. Or do I make a new php document on my ftp server and just have this on it? So that means if I do that then I send the form input to that document and where is says text in that document catch the form input there to be sent to me? Is that how I do it?

This is the script I am using right now to send form mail. It came with my ftp sever but takes way to long before I get the email and what I need is an instant email.
<?php
    $request_method = $_SERVER["REQUEST_METHOD"];
    if($request_method == "GET"){
      $query_vars = $_GET;
    } elseif ($request_method == "POST"){
      $query_vars = $_POST;
    }
    reset($query_vars);
    $t = date("U");

    $file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
    $fp = fopen($file,"w");
    while (list ($key, $val) = each ($query_vars)) {
     fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
     fputs($fp,"$val\n");
     fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
     if ($key == "redirect") { $landing_page = $val;}
    }
    fclose($fp);
    if ($landing_page != ""){
	header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
    } else {
	header("Location: http://".$_SERVER["HTTP_HOST"]."/");
    }


?>


#5 jwk811

jwk811
  • Members
  • PipPipPip
  • Advanced Member
  • 714 posts

Posted 25 September 2006 - 02:33 AM

I found this script to mail forms. Where would I put this and this seems a little too basic, is this all I'm going to need?
<?PHP 

## The lines below need to be edited... 

###################### Set up the following variables ###################### 
# 
$to = "you@your.com"; #set address to send form to 
$subject = "Results from your Request Info form"; #set the subject line 
$headers = "From: Form Mailer"; #set the from address, or any other headers 
$forward = 0; # redirect? 1 : yes || 0 : no 
$location = "thankyou.htm"; #set page to redirect to, if 1 is above 
# 
##################### No need to edit below this line ###################### 

## set up the time ## 

$date = date ("l, F jS, Y"); 
$time = date ("h:i A"); 

## mail the message ## 

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n"; 

if ($_SERVER['REQUEST_METHOD'] == "POST") { 
    foreach ($_POST as $key => $value) { 
        $msg .= ucfirst ($key) ." : ". $value . "\n"; 
    } 
} 
else { 
    foreach ($_GET as $key => $value) { 
        $msg .= ucfirst ($key) ." : ". $value . "\n"; 
    } 
} 

mail($to, $subject, $msg, $headers); 
if ($forward == 1) { 
    header ("Location:$location"); 
} 
else { 
    echo "Thank you for submitting our form. We will get back to you as soon as possible."; 
} 

?>
Please help.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users