-1

For some days i am trying to send email by using phpmailer which is correctly working on localhost but when i upload same project on the server email not send and also no errors return. this is happening on one.com.

But i have another server with the name inovexi when i upload on this server then email send.

i don't know what is matter actually behind this seen. Please guide me. Thanks.

i have used phpmailer in many projects before. I also have used swiftmailer as well.

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'vendor/autoload.php';

$mail = new PHPMailer(true);
try {
    $mail->SMTPDebug = 3;
    $mail->isSMTP();
    $mail->Host       = 'smtp.gmail.com';
    $mail->SMTPAuth   =  true;
    $mail->Username   = 'blackwindows321@gmail.com';
    $mail->Password   = 'AB11223344';
    $mail->SMTPSecure = 'tls';
    $mail->Port       =  587;

    $mail->setFrom("tayyabeng007@gmail.com", "Artizan");
    $mail->addAddress('tayyabeng007@gmail.com', "Artizan");
    $mail->addReplyTo('contact@artizan-texhnologies.com', 'reply-artizan');

    $mail->isHTML(true);
    $mail->Subject = "Artizan Contact Email";
    $mail->Body    = "This is test message";
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
    $mail->send();
} 

catch (Exception $e) 
{
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Tayyab Hanif
  • 21
  • 1
  • 6

1 Answers1

-1

I have no precise answer for you right now mate, but I do have a bit of advice to help you get there.

A blank page often means a HTTP 500 error, but you can't see it because of PHP configuration on the server.

Do you have access to any logs on this server ? Do you have a way to enable warning, error and exception display on this server ?

You probably can get something out of this exception, but 'echoing' it is not the proper way to handle it.

Use a logger if you can, or create a log table in your database, anything that would be convenient and doable for you.

kbj
  • 1
  • 1