Webmaster Forum


Go Back   Webmaster Forum > Marketing Forums > Marketing Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Marketing Forum Marketing, branding and advertising discussions. Online and off-line marketing discussions.

Directory Submission Service   I Sell Pagerank   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 12-09-2005, 10:28 AM   #1 (permalink)
Contributing Member
 
Join Date: 01-05-04
Posts: 90
iTrader: 0 / 0%
Latest Blog:
None

optic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebody
PHP Sendmail Tutorial

You can view this tutorial on: http://www.chauy.com/2005/11/php-sendmail-tutorial/

Sending email through PHP

Thousands of websites use contact forms to communicate with their users. You will have almost certainly seen one if not used one to contact someone. The contact form will take the users information that he or she has filled in then send the data over to our php script for processing. In our case the data will be sent over to us in an email.


Creating the HTML Feedback Form

Below is the HTML code to create our feedback form. If you need more information on HTML forms see our HTML forms article: http://www.chauy.com/2005/11/html-forms-tutorial/

< form method="post" action="sendmail.php">
Email: < input name="email" type="text" />
Message:
< textarea name="message" rows="10" cols="30">
< /textarea>
< input type="submit" />
< /form>

The form will take the email address and message from the user and sends the information to sendmail.php via the form, action=”sendmail.php”.

The php script will know which piece of information being sent by the input name=”" tag. So we know the email will be typed in the email box by the name tag: name=”email”

The PHP code to sendmail

Now we have set the form to POST the data to sendmail.php we need to create a new file named “sendmail.php”. Once you have created the file you can enter the following code into your empty php file. Don’t worry I’ll explain each line in a moment.

< ?
$email = $_GET['email'] ;
$message = $_GET['message'] ;
mail( "yourname@example.com", "Email Subject", $message, "From: $email" );
print "Congratulations your email has been sent";
?>

Okay this script will now send email out using php’s sendmail function yeh! Now I’ve got some explaining to do.

Line 2 - 3: These get the data from the form keeping in mind the email form box is named name=”email” and the $_GET variable is also called email.

Line 4: This is the clever part that sends the email, The mail() function allows to… specify the email address of the recipient, place the the subject of the email which will appear in the subject line, puts the message of the email which appears in the emails main body and the function allows you to specify the senders email so the recipient can then send a reply if required.

The sendmail function is no way limited to this configuration but as a beginner tutorial this is the minimum information you need to make mail() work.

For more information on the sendmail function then please goto phps sendmail function page.

line 5 - Will display “Congratulations your email has been sent”, Once the

I hope the tutorial helps any comments or question as always can be post below.
__________________
Hire a Blogger - Low cost blogger for hire.
optic5 is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 12-09-2005, 10:57 AM   #2 (permalink)
v7n Mentor
 
Sabeur's Avatar
 
Join Date: 12-04-05
Location: UK
Posts: 845
iTrader: 0 / 0%
Latest Blog:
Voyage a Paris

Sabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really nice
Send a message via MSN to Sabeur
nice, thnx it would help if u added
PHP Code:

so help spot the codes.
__________________
v7n Addict
Young Webdesigner & coder
HAHA I LOVE It
Sabeur is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-09-2005, 11:28 AM   #3 (permalink)
Contributing Member
 
Join Date: 01-05-04
Posts: 90
iTrader: 0 / 0%
Latest Blog:
None

optic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebody
I got lazy and forgot about BBcode lol

Whats the damn edit button?
__________________
Hire a Blogger - Low cost blogger for hire.
optic5 is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-10-2005, 03:01 AM   #4 (permalink)
v7n Mentor
 
Sabeur's Avatar
 
Join Date: 12-04-05
Location: UK
Posts: 845
iTrader: 0 / 0%
Latest Blog:
Voyage a Paris

Sabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really niceSabeur is just really nice
Send a message via MSN to Sabeur
use it and u will edit ur txt.
__________________
v7n Addict
Young Webdesigner & coder
HAHA I LOVE It
Sabeur is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-21-2005, 05:47 AM   #5 (permalink)
Inactive
 
Join Date: 12-21-05
Posts: 1
iTrader: 0 / 0%
Latest Blog:
None

Nykka is liked by many
Thanks for the tutorial... but, I have a problem!.

Hello!... i'm starting using PHP, and I made a form in my site to send mails with PHP. It's work perfect (thank you very much!) but the mails came empty to my outlook express. I mean, there's no text in the email!!!. I don't know how to fix it!. Sorry about my english, I'm from Argentina...
I hope one of you may help me.
This is the code I used in the page:

<body>
<form method="post" action="sending.php">
<p>Nombre:
<input name="nombre" type="text" />
</p>
<p>E-mail:
<input name="email" type="text" />
</p>
<p>Telefono:
<input name="telefono" type="text" />
</p>
<p>Mensaje:</p>
<p> <textarea name="message" rows="10" cols="30">
</textarea>
</p>
<p>
<input type="submit"/>
</p>
</form>

</body>
</html>

And this is the PHP code:

<?
$email = $_GET['email'];
$message = $_GET['message'];
mail("name@myemail.com", "Email Subject", $message, "From: $email", Nombre: $nombre", Telefono: $telefono");
print("Su mensaje ha sido enviado.");
?>

PD: The mail I used, is an example. I changed with my real mail.
Nykka is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-26-2005, 05:09 AM   #6 (permalink)
Junior Member
 
TotalDesain's Avatar
 
Join Date: 12-16-05
Posts: 20
iTrader: 0 / 0%
Latest Blog:
None

TotalDesain is on the right pathTotalDesain is on the right path
Send a message via Yahoo to TotalDesain
Your method is POST, but your form processor is GET
thinking about it...!

BTW, can we send mail with attached file by php mail ?
TotalDesain is offline  
Add Post to del.icio.us
Reply With Quote
Old 12-26-2005, 06:45 AM   #7 (permalink)
Inactive
 
MadKad's Avatar
 
Join Date: 12-14-05
Location: UK
Posts: 1,169
iTrader: 0 / 0%
Latest Blog:
Have your own blog

MadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web proMadKad is a highly respected web pro
nice tut mate
MadKad is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-03-2006, 08:19 PM   #8 (permalink)
Contributing Member
 
Join Date: 01-05-04
Posts: 90
iTrader: 0 / 0%
Latest Blog:
None

optic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebody
Quote:
Originally Posted by TotalDesain
Your method is POST, but your form processor is GET
thinking about it...!

BTW, can we send mail with attached file by php mail ?
Yes, you can send attachments with sendmail here is a tutorial about advanced emails which touches on attachments:

http://www.sitepoint.com/print/advanced-email-php
__________________
Hire a Blogger - Low cost blogger for hire.
optic5 is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-03-2006, 08:20 PM   #9 (permalink)
Contributing Member
 
Join Date: 01-05-04
Posts: 90
iTrader: 0 / 0%
Latest Blog:
None

optic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebodyoptic5 is liked by somebody
Quote:
Originally Posted by madkad
nice tut mate

Thanks Man,
__________________
Hire a Blogger - Low cost blogger for hire.
optic5 is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Marketing Forums > Marketing Forum

Reply



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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Verio Sendmail - Compare two files theChronic Coding Forum 5 06-16-2007 11:04 AM
Sendmail Problem :( sellingonline Dedicated Servers 11 01-12-2007 02:09 AM
PHP.ini and sendmail Trollmaster Coding Forum 0 07-09-2004 01:16 PM
Help with PHP Sendmail code: Zebra1 Coding Forum 0 06-17-2004 09:47 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 02:34 PM.
© Copyright 2008 V7 Inc

Click Here