Vote count:
0
I tried to send email through contact form i also write code to set SMTP in php.ini but every time its shows error. Tell me if I using yahoo account to get email then what i need to set in SMTP and smtp_port in php.ini. And Tell me same for Gmail also.
<?php
if(isset($_REQUEST['Submit'])){
/* These are the variable that tell the subject of the email and where the email will be sent.*/
$emailSubject = 'Customer Has a Question!';
$mailto = 'prajapat.ashish009@live.com';
/* These will gather what the user has typed into the fieled. */
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$questionField = $_POST['question'];
/* This takes the information and lines it up the way you want it to be sent in the email. */
$body = <<<EOD
<br><hr><br>
Name: $nameField <br>
Email: $emailField <br>
Question: $questionField <br>
EOD;
ini_set("SMTP","smtp.live.com");
ini_set("smtp_port","587");
$headers = "From: $emailField\r\n"; // This takes the email and displays it as who this email is from.
$headers .= "Content-type: text/html\r\n"; // This tells the server to turn the coding into the text.
$success = mail($mailto, $emailSubject, $body, $headers); // This tells the server what to send.
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ift.tt/kkyg93">
<html xmlns="http://ift.tt/lH0Osb">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form Sample</title>
</head>
<body>
<form id="form1" name="form1" method="post">
<table width="455" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="175" height="44" align="center"><label for"name">name</label></td>
<td width="280"><input name="name" type="text" id="name" size="30" />
</td>
</tr>
<tr>
<td height="45" align="center"><label for="email">email</label></td>
<td><input name="email" type="text" id="email" size="30" /></td>
</tr>
<tr>
<td height="41" align="center"><label for="question">question</label></td>
<td><textarea name="question" cols="30" rows="5" id="question"></textarea></td>
</tr>
<tr>
<td height="38"> </td>
<td><label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
asked 3 mins ago
How to Send Email Through Contact Form from localhost in php ?
Aucun commentaire:
Enregistrer un commentaire