I have been digging around to look for suggestions on how to ensure an email address that has been inputted in a web form is valid or not. It seems like the best solution is to send an automated email to the email address the user has submitted, if they receive it then great if not its obviously not valid.
what i want to do is have the user fill in the contact form, when they submit the form it checks all validation and then sends an automated email to the users email address, then depending on whether the email was successfully received send the original query to my email.
I can get the automated email sending ok but is there a way to get php to return a email received confirmation so that i can process the rest of my script?
here is my code
<?php
// if user has submitted the form and there are no errors
if(($_SERVER["REQUEST_METHOD"] == "POST") && !$nameErr && !$emailErr && !$phoneErr && !$messageErr && !$botErr && !$pointsErr)
{
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 0;
//Set the hostname of the mail server
$mail->Host = 'mailout.one.com';
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = 587;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = 'USERNAME';
//Password to use for SMTP authentication
$mail->Password = 'PASSWORD';
//Set who the message is to be sent from
$mail->setFrom($from, $name);
//Set an alternative reply-to address
$mail->addReplyTo($email, $name);
//Set who the message is to be sent to
$mail->addAddress($from, 'PERSON');
// To send automated reply mail
$autoemail = new PHPMailer();
$autoemail->From = $from;
$autoemail->FromName = "PERSON";
$autoemail->AddAddress($email, $name);
$autoemail->Subject = "Autorepsonse: We received your submission";
$autoemail->Body = "We received your submission. We will contact you soon ...";
$autoemail->Send();
if(!$autoemail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
//CHECK AUTOMATED EMAIL HAS BEEN RECEIVED BY THE USER THEN SEND THEIR ENQUIRY EMAIL
//Set the subject line
#$mail->Subject = $subject;
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
#$mail->Body = $message."<p><strong>Club Enquiry Relates To: </strong>".$club."</p><p><strong>Client Details</strong></p>Name: ".$name."<br/>Email: ".$email."<br />Tel No: ".$phone."<p><strong>Extras</strong></p>How Did you find our website? ".$hearsay."<br/ >Spam Score: ".$points." out of ".$maxPoints."<br />IP Address: ".$_SERVER['REMOTE_ADDR'];
//Replace the plain text body with one created manually
#$mail->AltBody = 'This is a plain-text message body';
//Attach an image file
#$mail->addAttachment('images/phpmailer_mini.png');
echo"<h2>Thank You!!!</h2>";
echo "<p>Your message has been sent successfully, we aim to respond within a couple of days. Please check your Junk/Span folder incase it ends up there.</p>";
}
But I'm unsure how to tell if the auto response email was delivered or not?
any help is greatly appreciated