Php Mail sent to spam recipients / junk folder

I work on my college website. I wrote a php script that sends an email using the php mail function . But the problem is that all the letters that I send are in the Spam / Junk folder of the recipients.

To solve the problem :

I tried all the steps and answers to similar problems in /qaru.site / ... and the serverfault site Like: * The correct header * Exact on behalf, etc. But the problem is not resolved.

This is the php code for sending email:

 <?php $from_address=" webmaster@ ".$_SERVER['SERVER_NAME']; $from_name="webmaster"; $headers = "MIME-Version: 1.0\r\n" ."Content-Type: text/plain; charset=utf-8\r\n" ."Content-Transfer-Encoding: 8bit\r\n" ."From: =?UTF-8?B?". base64_encode($from_name) ."?= <$from_address>\r\n" ."X-Mailer: PHP/". phpversion(); $subject="Web Mail Testing"; $body="This is test Message"; $to=" riteshkumargupta1990@gmail.com "; mail($to, $subject, $body, $headers, " -fwebmaster@ {$_SERVER['SERVER_NAME']}"); echo "The Mail is SuccessFully Sent to :".$to; ?> 

I also attach the original letter (which I received in my gmail account " riteshkumargupta1990@gmail.com ")

 Delivered-To: riteshkumargupta1990@gmail.com Received: by 10.204.8.210 with SMTP id i18csp146000bki; Wed, 21 Nov 2012 20:58:12 -0800 (PST) Received: by 10.68.219.164 with SMTP id pp4mr1119127pbc.72.1353560291776; Wed, 21 Nov 2012 20:58:11 -0800 (PST) Return-Path: < webmaster@nitw.ac.in > Received: from www.nitw.ac.in (www.nitw.ac.in. [218.248.13.200]) by mx.google.com with ESMTPS id sh10si3456960pbb.293.2012.11.21.20.58.10 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Nov 2012 20:58:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of webmaster@nitw.ac.in designates 218.248.13.200 as permitted sender) client-ip=218.248.13.200; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of webmaster@nitw.ac.in designates 218.248.13.200 as permitted sender) smtp.mail=webmaster@nitw.ac.in Received: from www.nitw.ac.in (localhost.localdomain [127.0.0.1]) by www.nitw.ac.in (8.13.8/8.13.8) with ESMTP id qAM50M0h016190 for < riteshkumargupta1990@gmail.com >; Thu, 22 Nov 2012 10:30:23 +0530 Received: (from nobody@localhost ) by www.nitw.ac.in (8.13.8/8.13.8/Submit) id qAM50McG016189; Thu, 22 Nov 2012 10:30:22 +0530 Date: Thu, 22 Nov 2012 10:30:22 +0530 Message-Id: < 201211220500.qAM50McG016189@www.nitw.ac.in > X-Authentication-Warning: www.nitw.ac.in: nobody set sender to webmaster@nitw.ac.in using -f To: riteshkumargupta1990@gmail.com Subject: Web Mail Testing X-PHP-Originating-Script: 0:mailer.php MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: =?UTF-8?B?d2VibWFzdGVy?= < webmaster@nitw.ac.in > X-Mailer: PHP/5.3.5 This is test Message 

In addition, during a Google search, I found an unusual cause for this type of problem: server Blacklisting .

Then I use the following tool to check it: http://www.mxtoolbox.com/SuperTool.aspx?action=mx%3anitw.ac.in#

I was shocked when the tool test described above found my server blacklisted. How is that right? Since the original mail I attached above says: " Received-SPF: pass (google.com: best guess record for domain of webmaster@nitw.ac.in designates 218.248.13.200 as permitted sender)

Also, if my server is blacklisted, how can I find the reason for the blacklist and how to solve it?

UPD: From Shadow Comment: Could "X-Authentication-Warning: www.nitw.ac.in: no one sent the sender to webmaster@nitw.ac.in using -f" msg be the likely cause? If so, how can I fix it?

Thanks!

+4
source share
1 answer

Setting up an SMTP server is a difficult and tedious task, unless ur does it day after day. Verify that your server’s SSL certificate is signed correctly using an authorized CA certificate. This can sometimes be a problem with self-signed certificates.

Or you can also try Gmail. As your SMTP server, which solves many problems .., Link

+2
source

Source: https://habr.com/ru/post/1447655/


All Articles