I am trying to use PHP\'s mail() function to send a test mail.
$to = \"****@gourab.me\";
$sub = \"Php Mail\";
$msg = \"Test Message From PHP\";
mail($to, $s
<?php
$to = "somebody@example.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: webmaster@example.com" . "\r\n" .
"CC: somebodyelse@example.com";
mail($to,$subject,$txt,$headers);
?>
<?php
if(isset($_POST['send'])){
$from = $_POST['femail'];
$phoneno = $_POST['phoneno'];
$message = $_POST['message'];
$carrier = $_POST['carrier'];
if(empty($from)){
echo("enter the email");
exit();
}
else if(empty($phoneno)){
echo("enter the phone no");
exit();
}
elseif(empty($carrier)){
echo("enter the specific carrier");
exit();
}
else if(empty($message)){
echo("enter the message");
exit();
}
else{
$message = wordwrap($message, 70);
$header = $from;
$subject = 'from submission';
$to = $phoneno.'@'.$carrier;
$result = mail($to, $subject, $message, $header);
echo("message sent to".$to);
}
}
?>
Bro it seems that you're using you own PC/localhost/127.0.0.1 server that's why you can't connect to SMTP server. You can only send mail from live server using similar coding with some amendments :) i.e. add one parameter "Header/From".
mail("You@me.com","Answer","Hope You Vote My Answer Up","From: me@you.com");
It seems your From
header is not correctly formatted. Try this instead:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Your name <info@address.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $body, $headers);