0

I created a HTML/PHP on my online contact form.

after insert all information ,and return to the index.html

i still don't receive any email from the website .

what should i do ? should i set the smtp?

I'm using smartermail pro 4.3 for my email.

<?php
if(isset($_POST['submit']))  {
   $msg = 'Company: '.$_POST['company']."\n"
   .'Address: '.$_POST['address']."\n"
   .'Website: '.$_POST['website']."\n"
   .'Your Contact: '.$_POST['contact']."\n"
   .'Email : '.$_POST['email']."\n"
   .'Remark : '.$_POST['remark']."\n";
   mail('sale@jadepack.com.sg', 'Online Enquiry', $msg);
   header('location: index.html');
} else {
   header('location: onlineenquiry.html');
   exit(0);
}


?>

[http://www.jadepack.com.sg/onlineenquiry.html![][1]][1]

[IMAGES FOR THE FORM][1]

qing
  • 67
  • 1
  • 10

2 Answers2

1

Search these files on google you will be redirected to github, Download the code from there.

1) class.smtp.php 2) class.phpmailer.php

Include these two files in the page sendemail.php (code given below)

require_once('class.phpmailer.php');
require_once('class.smtp.php');
require_once('upass.php');

function sendEmail($to, $subject,$message){
    $mail = new PHPMailer(); // defaults to using php "mail()"
    $name = explode('@',$to);
    $body = "Your email body goes here";

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug  = 0;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
global $username;
global $password;
$mail->Username   = $username;
$mail->Password   = $password;
$mail->CharSet    = 'UTF-8';

$mail->AddReplyTo("abc@abc.ae.com", "Notification");
$mail->SetFrom('abc@abc.ae.com', 'Notification');

$address = $to;
$mail->AddAddress($address, $name[0]);

$mail->Subject = $subject;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
if (!$mail->Send()) {
    //echo "Mailer Error: " . $mail->ErrorInfo;
} else {
    //echo "Message sent!";
}


}

//File upass.php code given below

<?php
$username   = "abc@abc.come";  // GMAIL username
$password   = "xyz";            // GMAIL password
?>
Abdul Moiz
  • 1,317
  • 2
  • 17
  • 40
  • This is how you can configure smtp on local. This is working piece of code. Hope this will help you. You just to change credentials and just copy paste !!! – Abdul Moiz Apr 27 '15 at 12:10
0

First I would be sure that mail function is sending an email. You can check it by puting the mail call inside and if inside your "onlineenquiry.php":

<?php
if(isset($_POST['submit']))  {
   $msg = 'Company: '.$_POST['company']."\n"
   .'Address: '.$_POST['address']."\n"
   .'Website: '.$_POST['website']."\n"
   .'Your Contact: '.$_POST['contact']."\n"
   .'Email : '.$_POST['email']."\n"
   .'Remark : '.$_POST['remark']."\n";

   if (mail('sale@jadepack.com.sg', 'Online Enquiry', $msg)) {
       header('location: index.html');
   } else {
       header('location: emailError.html');
   }
} else {
   header('location: onlineenquiry.html');
   exit(0);
}
?>

Then:

  1. Either you don't have mail server setup (contact your administrator)
  2. Or you are not using SMTP service to send the email.

As a suggestion, I'd recommend using a library that has SMTP support (using other accounts) with SSL and TSL and authentication, HTML-based emails... PHPMailer is one of the most famous. I'd encourage you to read about it and give it a try. This way you do not depend on your local host.

Here I link you a simple example from the library's repository.

Miguel
  • 141
  • 1
  • 12