send email template in php code example

Example 1: how to send email with php

<?php     
  

  var Name = $_POST('name');
  // grabbing the data from the form when posted
  // make sure to add name="name" or name="email"
  // in the input tag to grab the the specific elements
  // data example <textarea name="message"> or 
// <input type="number name="number">
  
  var Email = $_POST('email');
  var Number = $_POST('number');
  
$to_email = 'Your E-mail';
$subject = 'The Subject of the message';
$message = 'Name'.$name. "email" .$email. "number:" .$number.".";
$headers = 'From: noreply @ company . com'; //optional
mail($to_email,$subject,$message,$headers);
?>

Example 2: send email in php

<?php
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "[email protected]";
    $to = "[email protected]";
    $subject = "Checking PHP mail";
    $message = "PHP mail works just fine";
    $headers = "From:" . $from;
    if(mail($to,$subject,$message, $headers)) {
		echo "The email message was sent.";
    } else {
    	echo "The email message was not sent.";
    }
    ?>

Example 3: send email in php

<?php
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
    $from = "[email protected]";
    $to = "[email protected]";
    $subject = "Checking PHP mail";
    $message = "PHP mail works just fine";
    $headers = "From:" . $from;
    if(mail($to,$subject,$message, $headers)) {
		echo "The email message was sent.";
    } else {
    	echo "The email message was not sent.";
    }

Example 4: cpanel email to email send with php

<?php

//testing my first php mail()

mail('[email protected]', 'Subject Line Here', 'Body of Message Here', 'From: [email protected]');

?>

Tags:

Php Example