Ниже приведен код для отправки почты непосредственно из формы, но он не работает.
<?php
ini_set("include_path", '/home/ny1zdip8aag5/php:' . ini_get("include_path") );
include('Mail.php');
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$address = $_POST['address'];
$pan = $_POST['pan'];
$aadhar = $_POST['aadhar'];
$comp = $_POST['comp'];
$amount = $_POST['amount'];
$loss = $_POST['loss'];
$message = $_POST['message'];
$email_from = 'support@picors.com';//<== update the email address
$email_subject = "New Form submission from $name";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message".
"E-mail:\n $email".
"Mobile:\n $mobile".
"Address:\n $address".
"PAN:\n $pan".
"AADHAR:\n $aadhar".
"Complainant Company Name:\n $comp".
"Service Amount Paid To Company:\n $amount".
"Loss Amount:\n $loss".
$to = "suport@picors.com";//<== update the email address
$headers = array ('From' => $email,
'To' => $email,
'Subject' => $name);
$host = "**************";
$username = "*************";
$password = "***********";
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => "PLAIN",
'socket_options' => array('ssl' => array('verify_peer_name' => false)),
'username' => $username,
'password' => $password));
$mail = $smtp->send($to,$email_subject,$email_body,$headers);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
}
?>
Ниже приведен код формы.
<form method="post">
<div class="form-group">
<input type="text" name="name" class="form-control input-text" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
</div>
<div class="form-group">
<input type="email" class="form-control input-text" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" />
</div>
<div class="form-group">
<input type="text" class="form-control input-text" name="mobile" id="mobile" placeholder="Mobile Number" data-rule="minlen:4" data-msg="Please enter valid mobile number" />
<div class="form-group">
<input type="text" class="form-control input-text" name="address" id="Address" placeholder="Address" data-rule="minlen:4" data-msg="Please enter address here" />
</div>
<div class="form-group">
<input type="text" class="form-control input-text" name="pan" id="pan" placeholder="PAN Number" data-rule="minlen:4" data-msg="Please enter PAN number here" />
</div>
<div class="form-group">
<input type="text" class="form-control input-text" name="aadhar" id="aadhar" placeholder="ADHAAR Number" data-rule="minlen:4" data-msg="Please enter ADHAAR Number here" />
</div>
<div class="form-group">
<input type="text" class="form-control input-text" name="comp" id="comp" placeholder="Complainant Company Name" data-rule="minlen:4" data-msg="Please enter complainant company name here" />
</div>
<div class="form-group">
<input type="text" class="form-control input-text" name="amount" id="amount" placeholder="Service Amount Paid To Company" data-rule="minlen:4" data-msg="Please enter service amount paid to company here" />
</div>
<div class="form-group">
<input type="text" class="form-control input-text" name="loss" id="loss" placeholder="Loss Amount" data-rule="minlen:4" data-msg="Please enter loss amount here" />
</div>
<div class="form-group">
<textarea class="form-control input-text text-area" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Message"></textarea>
</div>
<div class="text-center"><input type="submit" name="submit" class="btn btn-default submit" value="Send Message" align="middle"/></div>
Ошибка: $ заголовки должны быть массивом