Jump to content

Mailing Forms


jwk811

Recommended Posts

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('[email protected]');
$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]
Link to comment
https://forums.phpfreaks.com/topic/21914-mailing-forms/#findComment-97895
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 = "[email protected]"; #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.
Link to comment
https://forums.phpfreaks.com/topic/21914-mailing-forms/#findComment-97908
Share on other sites

Archived

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

×
×
  • Create New...

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.