NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > Webmaster Tutorials
Reload this Page mail()

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search
0 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 03-04-2006, 01:22 PM THREAD STARTER               #1 (permalink)
NamePros Regular
 
asgsoft's Avatar
Join Date: Sep 2005
Location: At Home
Posts: 881
asgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of lightasgsoft is a glorious beacon of light
 



mail()


I think is subforum is a great idea, so i decided to do something in it. A famous function, yet mis-used is mail().

Mail function can be used in several ways, eg a contact form and auto-senders suitable for confirming registeration.

Ok the function is used like this:

PHP Code:
mail($to$subject$message$headers); 
you can either set the varaibles or enter them manually like this:

PHP Code:
mail(myemail@mycompany.commessage subjectmessage headers); 
Although its prefered to use variables becuae its easier to use and modify later.

To make sure the message was sent correctly you can use the following "if block"
PHP Code:
if(mail($to,$subject,$message,$headers)){
echo 
"Email Sent";
}else{
echo 
"Email Sending Failed";
????: NamePros.com http://www.namepros.com/webmaster-tutorials/173481-mail.html

If you are making an autosender you add this to the page that has the email address passed in most propably by a form, so you do this:
PHP Code:
$to="someeila@comapny.com";
$from=$_POST['email'];
$message="my message";
$subject="Subject of message";
$headers "From: $from";
if(
mail($to,$subject,$message,$headers)){
????: NamePros.com http://www.namepros.com/showthread.php?t=173481
echo 
"Email Sent messaage";
}else{
echo 
"Email Sending Failed mesasage";

The other emaple i mentioned at the begginig was the contact form, look at this form, it has both parts in one php page:
PHP Code:
<?php
if(!isset($submit)){
echo 
"<form action='$_SERVER[PHP_SELF]' method='post'>
<p>Name: <input type='text' name='name'><br><p>
<p>Email: <input type='text' name='email'><br><p>
Message: <br>
<textarea name='message' cols='40' rows='15'></textarea><br>
<input type='submit' name='submit' value='send'>
</form>"
;
}else{
$to="asmgomaa@gmail.com";
$from=$_POST['email'];
$message=$_POST['message'];
$subject="Website Contact Form";
$submit=$_POST['submit'];
$headers "From: $from";
if(
mail($to,$subject,$message,$headers)){
echo 
"Email Sent";
}else{
echo 
"Email Sending Failed";
}
}
?>
an example of it is available here .

I hope this is helpful and makes the mail() function clear and easier to use.
asgsoft is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fan Mail Contest $50-$200 (depending on participation) thebestsean Contests Forum 2 10-06-2005 05:12 PM
All about the mail function in PHP. bbalegere Programming 1 08-19-2005 09:25 PM
AIM Mail: 2GB Stephen Industry News 31 08-09-2005 01:24 AM
<< Mail * Mail * Mail >> domainsusi Domains For Sale - Make Offer 10 09-01-2004 03:57 PM

 
All times are GMT -7. The time now is 12:57 AM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger