Solved

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

Posted on 2004-08-23
5
179 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT 5 47
Build and evolve an interactive experience 1 96
Swiper slider stops between pages 11 51
Cordova Camera plugin fails 2 140
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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)

856 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