Categories: eLearning

Send Email using PHP – TechnoGripper India

Today, TechnoGripper India comes with an example to send email using PHP Script. For sending emails, PHP must be configured perfectly in php.ini file.

In PHP, You can send an email by using predefined PHP Function – mail(). This function needs 3 mandatory arguments that include the receiver’s mail id, a subject for the mail and the actual message content of the mail additionally there are two more variables that are non-mandatory.

Here are details of all the five functions:
to: Receiver Email ID
subject: Subject Line of the Email Message
message: Defines the message content to be sent to the Email
headers: Specifies additional headers, like From CC, BCC. Or if you want to send HTML email then also you need to use headers as a parameter. It should be CRLF separated
parameters: Specifies an additional parameter to send email using mail()



Here is Syntax to Send Email using PHP:

<?php
$to = "somebody@domain.com, somebodyelse@domain.com";
$subject = "Send Email using PHP";

$message = "
<html>
<head>
<title>HTML Message Content</title>
</head>
 <body>
 <p>This email contains HTML Tags!</p>
 <table>
  <tr>
   <th>Firstname</th>
   <th>Lastname</th>
  </tr>
  <tr>
   <td>John</td>
   <td>Doe</td>
  </tr>
 </table>
 </body>
</html>";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// More headers
$headers .= 'From: XXXX XXXX<mail@domain.com>' . "\r\n";
$headers .= 'Cc: boss@domain.com' . "\r\n";

mail($to,$subject,$message,$headers);
?>

If your script sent email successfully then the function mail() returns true otherwise it will return false.

That’s All to Send Email using PHP.
Any Query, Send us an Email at info@technogripper.net. We are always there to help volunteers and passionate peoples.

Recent Posts

Mistakes of Entrepreneurs: Deadly Mistakes of Entrepreneurs

The mistakes of entrepreneurs can be one of the costliest mistakes. Not only it can cost your business, but it…

4 days ago

Top Young Entrepreneurs from India, you must know about

Today, We'll featuring top young entrepreneurs from India, who have actually inspired entrepreneurs across the world. India has one of…

1 week ago

नए उद्यम विकास को प्रभावित करने वाले कारक।

भारत में उद्यमिता विकास  को प्राभावित करने वाले कारण निम्न हैं। जैसे : -  आर्थिक, सामाजिक और सांस्कृतिक , मनोवैज्ञानिक,…

1 month ago

उद्यमियों (एंटरप्रेन्योर) के लिए कौन सी योजना उपलबध है

भारत सरकार ने हमेशा से ही उद्योग के क्षेत्र को बढ़ावा देने की कोशिश की है. देश में उद्यमियों की…

2 months ago

उद्यमियों ( एंटरप्रेन्योर ) के लिए वैश्विक समस्या क्या है

किसी भी देश में आर्थिक विकास की गति को बढ़ावा देने तथा व्यावसायिक समस्याओं का समाधान करने में उद्यमी की…

2 months ago

Cocofit Has Raised INR 5 Crores From Shark Tank India

The shark tank India startup Cocofit has raised an unconventional amount of 5 rupees for the equity of 5% from…

2 months ago

REACH US

WEXT India Ventures

C-22, Sector 65, Noida, Uttar Pradesh – 201301

Corporate Queries:

Email: ping@wext.in
Mobile: +91 956 085 0036

Advertisement Queries:

Email: advertise@wext.in
Mobile: 956 085 0036