How can I send email with php

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

Page 1 of 1

2 Replies - 2777 Views - Last Post: 02 July 2008 - 11:06 AM Rate Topic: -----

#1 Hijibiji  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 02-July 08

How can I send email with php

Post icon  Posted 02 July 2008 - 06:10 AM

I want to send Email from my website. Here I have used form. How can I send email from this from field using PHP.
Is This A Good Question/Topic? 0
  • +

Replies To: How can I send email with php

#2 joeyadms  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 41
  • View blog
  • Posts: 178
  • Joined: 04-May 08

Re: How can I send email with php

Posted 02 July 2008 - 06:41 AM

Easily my friend.
<?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
Was This Post Helpful? 0
  • +
  • -

#3 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Re: How can I send email with php

Posted 02 July 2008 - 11:06 AM

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1