Jump to content

Archived

This topic is now archived and is closed to further replies.

jwk811

Mailing Forms

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Plan A: read the manual -> http://ca.php.net/manual/en/ref.mail.php

Plan B: search these forums for mail()

Either/both will show you how to.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Okay so all I have to do is add this to my script?
[code]<?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;

?>
[/code]
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.
[code]<?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"]."/");
    }


?>
[/code]

Share this post


Link to post
Share on other sites
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?
[code]<?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.";
}

?> [/code]
Please help.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.