Asked By
marcia
10 points
N/A
Posted on - 07/20/2011
I made the contact us form on the web. Â Connected with the email server (while wearing my email). Script as follows:
<?php
$to = "
[email protected]" ;
$subject = "From Contact Us";
$nama = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phonenumber'] ;
$pesan = $_REQUEST['message'];
$headers = "From: $nama<$email>";
$message = "[Nama : $nama], [E-mail : $email], [Phone : $phone], [Pesan : $pesan]";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{
?>
<script type='text/javascript'>
alert ('Thank you for sending an email to us…');
window.location="http://gmail.com";
</script>
<?php
}
else
?>
<script type='text/javascript'>
alert (message failed to send, please resend!');
window.location="http://gmail.com";
</script>
<?php
?>
in his field of existing html <form method="POST" name="form1" action="actioncontact.php" method='POST'>
have been tried was called, but why the error continues?
Error in question here was fitting already sent to the email server is not complete…
sometimes the phone number does not appear.
sometimes the message does not appear.
when all variables are adjusted.
It’s why we think so?
Answered By
marjune
0 points
N/A
#84752
Form contact us connected with email server
HI, i feel the same way with this issue, because i used mail(); function way back bafeore and its sucks. the best solution in this case is phpmailer. It is a full featured email transfer class for PHP that exposes a much greater range of features than the standard PHP mail() function. i used it not only once but many times and fulfill my needs. seeting up phpmailer is pretty much easy. you can down load it here https://sourceforge.net/projects/phpmailer/ and put it on your project.
how to confgure phpmailerÂ
 <?php
 Â
Â
 function sendmail($email, $subject, $body){
Â
 require_once('phpmailer/phpmailer_pi.php');
Â
 $mail=new PHPMailer();
Â
$mail->IsSMTP();
//$mail->SMTPAuth  = true;          // enable SMTP authentication
$mail->SMTPSecure = 'ssl'; Â Â Â Â Â Â Â Â
$mail->Host    = "hostname";//example gmail.com   Â
$mail->Port    = 465;          Â
Â
$mail->Username  = "hostusername";
$mail->Password  = "hostpassword";
Â
Â
 $mail->From    = "fromemail";
 $mail->FromName  = "fromName";
 $mail->Subject   = "subject";
 $mail->Body    = $body;       Â
 //$mail->AltBody   = "This is the body when user views in plain text format";
Â
 $mail->WordWrap  = 50; // set word wrap
Â
 $mail->AddAddress($email);
 //$mail->AddAttachment("/path/to/file.zip");       // attachment
 //$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment
Â
 $mail->IsHTML(true); // send as HTML
Â
 if(!$mail->Send()) {
print "Mailer Error: " . $mail->ErrorInfo;
 }Â
  Â
  }
?>
Â
just call the function sendmail($email, $subject, $body)Â
instead of mail($to, $subject, $message, $headers) ;
Â
Â
Answered By
marcia
10 points
N/A
#84754
Form contact us connected with email server
LOL I am missing that function..
Thanks  Marjune for the reason being that this is such an informative post.
Â
Â