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

Join 109,295 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,183 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! 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 - 06: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 - 06:41 AM
Post #2


D.I.C Head

Group Icon
Joined: 4 May, 2008
Posts: 145



Thanked 6 times

Dream Kudos: 600
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 - 11:06 AM
Post #3


D.I.C Regular

Group Icon
Joined: 25 Feb, 2008
Posts: 410



Thanked 16 times

Dream Kudos: 700
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: 9/6/08 09:25AM

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