Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,488 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,090 people online right now. Registration is fast and FREE... Join Now!




How can I send email with php

 
Reply to this topicStart new topic

How can I send email with php, I want to send email from form field. How can I do that using PHP?

Hijibiji
post 2 Jul, 2008 - 05:10 AM
Post #1


New D.I.C Head

*
Joined: 2 Jul, 2008
Posts: 1

I want to send Email from my website. Here I have used form. How can I send email from this from field using PHP.
User is offlineProfile CardPM

Go to the top of the page

joeyadms
post 2 Jul, 2008 - 05:41 AM
Post #2


D.I.C Head

Group Icon
Joined: 4 May, 2008
Posts: 145



Thanked 6 times

Dream Kudos: 600

Expert In: PHP, Web Security

My Contributions


Easily my friend.
CODE

<?php

$subject = $_POST['subject'];
$to = $_POST['to'];
$body = $_POST['body'];
$from = "no-reply@mysite.com" // Optional
$headers = "From: $from"; // Optional

mail($to,$subject,$body,$headers);




Use/modify as needed
User is offlineProfile CardPM

Go to the top of the page

akozlik
post 2 Jul, 2008 - 10:06 AM
Post #3


D.I.C Addict

Group Icon
Joined: 25 Feb, 2008
Posts: 596



Thanked 22 times

Dream Kudos: 750
My Contributions


Good enough joey.

@Hijibiji - The method is different for sending HTML e-mails. You need to include some more information in your headers, such as the Content-Type. What joey has will be great for just plaintext e-mails.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 04:21PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month