Solved

simple script to send out an email when user clicks a button...

Posted on 2004-08-23
5
178 Views
Last Modified: 2010-08-05
Hi,

I am trying to make a page that I will have a friend visit and will send them an email from me.

When they go to the page. there will be a "submit" button... when they click on that it will mail out an email to their address (something I already defined in the code itself... allthat page has is a button).

so i want them to click that button and I want a pre-programmed email to go out.

i was wondering how i can do this... i have a webserver compatible with most web languages.

it doesnt have to be anythin fancy... the body of hte message can even be encoded in hidden fields on the page itself... all the sameto me.

thanx in advanced for the help!

0
Comment
Question by:damn_computer
  • 2
5 Comments
 

Author Comment

by:damn_computer
ID: 11876105
nevermind... i found it here:

http://email.about.com/cs/phpemailtips/qt/et031202.htm

now how do i configure my server so it doesnt say from: "Nobody" and it says my name instead... or even better... is there somehting I can add to the code from there to make it say that?

<?php
$to = "email.guide@about.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body))
{
   echo("<p>Message sent!</p>");
}
else
{
   echo("<p>Message delivery failed...</p>");
}
?>

0
 
LVL 11

Expert Comment

by:neester
ID: 11877079
Hey DamnComputer,

Easy,

<?php
$to = "email.guide@about.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$header = "from: whoeveryouare@whateverdomain.com\n";
if (mail($to, $subject, $body,$header))
{
   echo("<p>Message sent!</p>");
}
else
{
   echo("<p>Message delivery failed...</p>");
}
?>


That should work jsut fine
0
 
LVL 11

Accepted Solution

by:
neester earned 60 total points
ID: 11877093
IF YOU WANT TO MAKE THE EMAIL HTML USE THIS ONE...



<?php
$YOUREMAIL = 'whoeveryouare@whateverdomain.com';

$to = "email.guide@about.com";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$header = "From: $YOUREMAIL\r\n";
$header .= "X-Sender: $YOUREMAIL\r\n";
$header .= "Content-type: text/html\r\n";
if (mail($to, $subject, $body,$header))
{
   echo("<p>Message sent!</p>");
}
else
{
   echo("<p>Message delivery failed...</p>");
}
?>




That should work just fine!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to i line up css containers from left to right 35 23
PHP email variable syntax 3 52
Problem to run file 9 117
Import data into excel from web page 10 98
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question