Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 68
How to translate path in URL with PHP? 11 31
I starting with php 12 94
API Soap Calls 4 59
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now