Solved

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

Posted on 2004-08-23
5
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
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.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

729 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