What is the Issue?
Website is having a contact form when user fill out it and proceed further by submitting it which will send the success message to the users but its showing blank page with no error message and even email is not receiving on other end. If you are facing this issue on your VPS and Cloud Server, then ensure that your MX record is pointing to some other hosting provider, if not then you need to proceed further with the following steps mentioned by us below.
Why has this issue occurred?
Even though this issue is related to your source code level Design Webtech is ready to help you in resolving the problem.This problem or issues may be due to any one of the following problem related Shared, VPS or Cloud Server:
- MX Record is pointing to some other hosting provider,which needs to be pointed to your ip address where your domain is hosted.
- You have given wrong port number on your php mailer source code or missed any source codes for example class.smtp.php that needs to be included.It may also due to authentication failures like servers will not allow to send the mail without encryption so you need to enter SMTPSecure = ‘tls’ as well as setting proper username and password properties.
- Your IP may be blocked due to continuous spam mail generation and email providers like zoho or gmail will notify these messages and they will block your IP it may be done immediately or it may reflect after some days.
How can we prevent it?
Use the below Source Code of PHP Mailer Provided By Design Webtech along with your appropriate authentication details:
File Name: Sendmail.php
<?php
function sendnewmail($msgnew,$emailidnew,$subjectnew)
{
require_once("class.phpmailer.php");
require_once("class.smtp.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.gmail.com"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username ="demo@gmail.com"; // SMTP username
$mail->Password ="demo123"; // SMTP password
$mail->From = "designwebtechdemo@gmail.com";
$mail->FromName = "DesignWebtech";
$mail->AddAddress($emailidnew," ");
//$mail->AddAddress("ellen@example.com"); // name is optional
//$mail->AddReplyTo("info@example.com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$mail->SMTPDebug = 2;
$mail->Subject = $subjectnew;
$mail->Body = $msgnew;
//$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
}
$htmldetails ="Welcome to Design Webtech";
$email = "designwebtech91@gmail.com";
$subject = "Sample welcome message";
sendnewmail($htmldetails,$email,$subject);
?>
Other 2 files you can download from github i.e class.smtp.php,class.phpmailer.php
URL: https://github.com/PHPMailer/PHPMailer/releases
Under class.smtp.php you need to enter port number as 25
EX: const DEFAULT_SMTP_PORT = 25;
public $SMTP_PORT = 25;
Under class.phpmailer.php you need to enter port number as 25
Ex: public $Port = 25;
Once everything got fixed, your php mailer starts working next check whether mail is going to inbox or spam.If mails are in spam then you need to verify that SPF and DKIM records are present or not for your domain name.Contact our support team to configure those records once it is done you need to wait for 24 hours propagation time.
Also make sure that your IP is not blacklisted, if so than you need to send request to whitelist the IP address.IP Blacklisting can checked through MX toolbox entering your domain name or IP address, it will display the details from where your ip address has been blacklisted and reason behind it.
Note: You can check the mail and domain error logs using the command:
tail -f /var/log/maillog