send mail using php localhost code example
Example 1: send email xampp
Go to C:\xampp\php [mail function]
SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
Example 2: 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 3: send email xampp
C:\xampp\sendmail [sendemail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=Your-Gmail-Password
[email protected](optional)
Example 4: 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.";
}
?>