I am having an issue while sending email query to multiple emails account in php, can anybody help here is the form HTML version
<form id="contact-form" action="#">
<div class="form-field-item">
<input type="text" required="required" name="fullname" id="fullname" size="25" placeholder="Name" class="form-field">
</div>
<div class="form-field-item">
<input type="tel" id="phone" name="phone" required="required" placeholder="Contact Number" class="form-field">
</div>
<div class="form-field-item">
<input type="email" required="required" name="email" id="email" placeholder="Email" class="form-field">
</div>
<div class="form-field-checkbox-item">
<div class="checkbox-item">
<input type="checkbox" id="agree-gdrp" name="agree-gdrp" required="required" value="Yes">
<label for="agree-gdrp" class="field-label">I agree that Fraser handles my personal data in accordance with GDPR</label>
</div>
</div>
<div class="form-submit-wrap">
<button>Send Enquiry</button>
</div>
</form>
… and here is the PHP:
<?php
$recepient = "[email protected],[email protected]";
$sitename = "Fraser";
$fullname = trim($_POST["fullname"]);
$email = trim($_POST["email"]);
$phone = trim($_POST["phone"]);
$message = "Name: $fullname nContact Number: $phone nEmail: $email";
$pagetitle = "Fraser Contact Form";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset="utf-8"n From: [email protected]");
?>
3
Answers
More and more hosters are going to block the sending of mails send to multiple recipents using the mail() function since you can provide any “From” address which may be blocked by the recipents due to SPF checks.
You may build up a whole SMTP connection to send your mail, maybe by using a Lib like the SwiftMailer.
Try this
it will work if your host doesnt block, if does! then you will need to use smtp like gmail or other providers.
Alternate you can use PHPMailer
How are you sending the data to be processed by php. i have added a script to the form action and replaced your submit button with an input of type submit
HTML
my_processing_script.php
If you dont want to leave the page i would suggest posting the form via ajax or jquery post
JQuery