Click to See Complete Forum and Search --> : e-mail info send by e-mail


tetu
09-19-2003, 11:44 PM
i would like to send a sort of template with information as chosen by the user in a form of an e-mail. Do you have an idea how to formulate this template to be send by e-mail. The server fills in the e-mail and send it to a pre set e-mail address. Is there a sort of script?
Thanks in advance

spykemitchell
09-20-2003, 06:09 AM
What kind of info do you want to send?

Name / Email Address / Comments ?

tetu
09-20-2003, 08:40 AM
i would like to send info like name surname and other fieleds filled in with numbers but not all the fields must be filled out only the fields with name, surname and address must be filled

spykemitchell
09-21-2003, 09:39 AM
This script allows you to send a name an email address and a comments section...

INSERT THIS INTO YOUR HTML DOCUMENT

<table>

<tr>
<td><div id="scroll3" style="width:100;height:25;overflow:none"><font face="arial" color="#ffffff" size="2">Name:</td>
<td><form action="mailer.php" method="post">
<input type="text" size="22" name="name"><br></td>
</tr>
<tr>
<td><div id="scroll3" style="width:100;height:25;overflow:auto"><font face="arial" color="#ffffff" size="2">Email: <br></td>
<td><input type="text" size="22" name="email"><br></td>
</tr>
<tr>
<td><div id="scroll3" align="top" style="width:100;height:30;overflow:auto"><font face="arial" color="#ffffff" size="2">Question: <br></td>
<td><textarea cols="17" rows="5" name="message"></textarea><br></td>
</tr>
</table>
<table>
<td><div id="scroll3" align="center" style="width:200;height:50;overflow:auto;"><input type="submit" name="submit" value="Submit Form"><br>
</form>
</tr>
</table><br><br>



PUT THIS AS A STANDALONE SCRIPT IN THE SAME DIRECTORY AS YOUR PAGE

<?PHP

$to = "email@address.com"; # This is who the form is sent to
$subject = "Subject"; # This is the ubject
$headers = "From: "; # This is the header in the email
$forward = 1; # redirect? 1 : yes || 0 : no
$location = "thankyou.htm"; # Where do you want your visitor to be redirected after sending the email?

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

$msg = "The Following Help Message Was Sent 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 "Thankyou For Sending Your Email. We Will Reply Soon.";
}

?>


If you need more help just ask!

Spyke.

buddybear
09-21-2003, 11:45 AM
I'm trying to accomplish the same thing but have a question.

The form I'm working on was made for mailto and I was advised to use PHP instead. When the form is sent I want to receive the form results by e-mail and I want the sender to be directed to a confirmation page.

Where do I add the script to my form and how do I add this as a stand alone script in the same directory as my page?

Thanks in advance.

pyro
09-21-2003, 01:01 PM
A couple of things. First of all, spykemitchell, is there a reason you posted my mailer.php code minus the copyright headers? Generally, it's considered good practice when you take someone else's script, to give them the credit. :rolleyes:

Anyway, the original in all it's glory can be found at http://www.webdevfaqs.com/php.php#mailer, which will also help buddybear out, as it contains the readme/documentation.

spykemitchell
09-21-2003, 01:12 PM
He he :p

That wasn't done on purpose, i took out the comments becuse i was having difficulty making it run on abyss and then copied the script straight out of my .php document...

Sorry about that... tell you what...

ADD THIS AT THE TOP OF THE PHP SCRIPT

# Copyright Pyro NOT Spyke Mitchell.
# Spyke Mitchell is a script theiving,
# Copyight removing,
# evil snivelling toerag and doesn't deserve to lick the groud where pyro has walked...
# Remember Pyro Good, Spyke EVIL LITTLE SOD!

Do you feel better for that Pyro????

:D ;) :p

pyro
09-21-2003, 01:15 PM
Nope, that's not necessary either. Just some mention that the script was originally created by me when you post it would be appreciated, and you might even find it easier to link to it on http://www.webdevfaqs.com/php.php#mailer than to post the code directly.

spykemitchell
09-21-2003, 01:39 PM
Where's your sense of humor mate?

It's not even on the web yet, just sitting on my computer and you made it perfectly clear that it was your script, Not that comments matter because as i was told you cant even view the source of a PHP script on the net anyway....

All you moderators should liven up a bit and have a nice cold german beer...

buddybear
09-21-2003, 01:42 PM
Thank you both for your reply.
So I need to place the HTML in my form script replacing all the mailto code.

I'm still not sure what you mean when you say to 'Put this as a stand-alone script in the same directory as your page'

My host supports PHP, do I have to do anything on their end?
Thanks

pyro
09-21-2003, 01:48 PM
Did you download the mailer.zip file from the link above and read the readme? It should explain it all to you.

buddybear
09-21-2003, 01:49 PM
Pyro,
When I download your files and unzip them the mailer is in a format that tries to open in printshop so I can't open that file Can you please post that file only?
Thanks

spykemitchell
09-21-2003, 01:58 PM
Thats because certain programs use the same file type as .php scripts....

to edit it you need to right clik it and select open with > Notepad

and you will see the script....

Just place the script saved as .php on your server and the html with the mail to replaced with the form i posted in the same directory and you are good to go...

buddybear
09-21-2003, 02:10 PM
Thanks. I was able to open the file.
I should be able to get to trying the script later today. Do I need to contact my host to place the script on the server or do I just uplaod it with FTP?

pyro
09-21-2003, 03:18 PM
Just upload it with FTP. Unlike Perl script, PHP can be run from any directory on the server.

tetu
09-21-2003, 03:48 PM
when i'm trying the pho example it comming the php script and no e-mail is send what could be the problem ???
thank you

pyro
09-21-2003, 03:51 PM
Does your server support PHP? You can check by naming this test.php and uploading it to your server:

<?PHP
echo "I have PHP!";
?>

tetu
09-21-2003, 03:54 PM
as a server i'm using tomcat and when i tried that you gave me and went on it the php file was opened in the web browser. what server should i use??

pyro
09-21-2003, 04:05 PM
If you have control over your server, just download (http://www.php.net/downloads.php) PHP and install it...

tetu
09-21-2003, 04:19 PM
how do you install it using windows?? in which directory you need to place it ??

pyro
09-21-2003, 04:27 PM
You can download the Window's installer (http://us4.php.net/get/php-4.3.3-installer.exe/from/a/mirror), and for my testing server, I just put it in the default directory of C:\PHP

buddybear
09-22-2003, 10:37 AM
Thanks for your help. It works fine.

pyro
09-22-2003, 11:37 AM
No problem... :)