email

How to send email using PHP?

Nowadays email communication is very important, So now will see how to send email using PHP.

Find below code:

<?php
$com_email = "mail@yourdomain.com"; // your domain email
$to = "yourmail@gmail.com";  //to whom you want to send email
$subject = "My subject"; //your email subject
$txt = "Hello world!"; //your email message/content
$headers = "From: Survey Form <$com_email> \r\n";  //to avoid spam
mail($to,$subject,$txt,$headers,"-f$com_email"); //to avoid spam
?>
Tagged as: