{"id":52,"date":"2014-02-11T22:29:21","date_gmt":"2014-02-11T22:29:21","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=8"},"modified":"2014-02-11T22:29:21","modified_gmt":"2014-02-11T22:29:21","slug":"troubleshoot-qmail-spam","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2014\/02\/11\/troubleshoot-qmail-spam\/","title":{"rendered":"Troubleshoot Qmail Spam"},"content":{"rendered":"<p>Is the server sending spam. Try this.<br \/>\nhttp:\/\/kb.parallels.com\/766<\/p>\n<p>First, check that all domains have the option \u2018Mail to non-existing user\u2019 set to \u2018reject\u2019 but not to \u2018forward.\u2019 You can change this setting to all domains using \u201cGroup Operations\u201d in the \u201cDomains\u201d tab in Parallels Plesk Control Panel. The option \u201cReject mail to nonexistent user\u201d is available since Parallels Plesk Panel 7.5.3.<br \/>\nAlso check that all the IPs and networks in the white lists are reliable and familiar to you.<\/p>\n<p>Check how many messages are in the queue with Qmail:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# \/var\/qmail\/bin\/qmail-qstat\n<\/pre>\n<p>messages in queue: 27645<br \/>\nmessages in queue but not yet preprocessed: 82<\/p>\n<p>If the queue has too many messages, try to discover the source of SPAM.<\/p>\n<p>If mail is being sent by an authorized user but not from the PHP script, you can run the command below to find the user that has sent the most messages (available since Plesk 8.x). Note that you must have the \u2018SMTP authorization\u2019 activated on the server to see these records:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># cat \/usr\/local\/psa\/var\/log\/maillog |grep -I smtp_auth |grep -I user |awk &#039;{print $11}&#039; |sort |uniq -c |sort -n\n<\/pre>\n<p>The path to \u2018maillog\u2019 may differ depending on the OS you are using.<\/p>\n<p>The next step is to use \u201cqmail-qread,\u201d which can be used to read the message headers:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># \/var\/qmail\/bin\/qmail-qread\n<\/pre>\n<p>18 Jul 2005 15:03:07 GMT #2996948 9073 &lt;user@domain.com&gt; bouncing<br \/>\ndone remote user1@domain1.com<br \/>\ndone remote user2@domain2.com<br \/>\ndone remote user3@domain3.com<br \/>\n&#8230;.<\/p>\n<p>This shows the senders and recipients of messages. If the message contains too many recipients, probably this is spam. Now try to find this message in the queue by its ID ( # 2996948 in our example):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># find \/var\/qmail\/queue\/mess\/ -name 2996948\n<\/pre>\n<p>Examine the message and find the line \u201cReceived\u201d to find out from where it was sent for the first time. For example, if you find:<\/p>\n<p>Received: (qmail 19514 invoked by uid 10003); 13 Sep 2005 17:48:22 +0700<\/p>\n<p>it means that this message was sent via a CGI by user with UID 10003. Using this UID, it is possible to find the domain:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># grep 10003 \/etc\/passwd\n<\/pre>\n<p>If the \u2018Received\u2019 line contains a UID of a user \u2018apache\u2019 (for example invoked by uid 48), it means that spam was sent through a PHP script. In this case, you can try to find the spammer using information from spam email (address from\/to or any other information). It is usually very difficult to discover the source of spam. If you are absolutely sure that this time there is a script which sends spam (tail grows rapidly for no apparent reason), you can use the following script to determine what PHP scripts are running at this time:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># lsof +r 1 -p `ps axww | grep httpd | grep -v grep | awk &#039; { if(!str) { str=$1 } else { str=str&quot;,&quot;$1}}END{print str}&#039;` | grep vhosts | grep php\n<\/pre>\n<p>You can also apply the KB article which describes the procedure of discovering which domains are sending mail through PHP scripts.<\/p>\n<p><a href=\"http:\/\/kb.sp.parallels.com\/en\/766\" target=\"_blank\" rel=\"noopener\">http:\/\/kb.sp.parallels.com\/en\/766<\/a><\/p>\n<p>Lines in Received section like<\/p>\n<p>Received: (qmail 19622 invoked from network); 13 Sep 2005 17:52:36 +0700<br \/>\nReceived: from external_domain.com (192.168.0.1)<\/p>\n<p>means that the message has been accepted and delivered via SMTP, and that the sender is an authorized mail user.<\/p>\n<p>Check the emails going out and look for a sending user that is in plesk:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cat \/usr\/local\/psa\/var\/log\/maillog | grep \u2018validuser@user@domain.com\u2019\n<\/pre>\n<p>Output:<\/p>\n<p>Nov 7 10:01:07 mail smtp_auth: SMTP user @user@domain.com : logged in from (null) [188.xx.xx.xx]<\/p>\n<p>The multiple IP logins show that the spam is from a valid user.<\/p>\n<p>Check email passwords:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">mysql -uadmin -p`cat \/etc\/psa\/.psa.shadow ` psa -e \u2018select m.mail_name,a.password,d.name from mail m,accounts a,domains d where m.account_id=a.id and m.dom_id=d.id;\u2019\n<\/pre>\n<p>Or <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# \/usr\/local\/psa\/admin\/bin\/mail_auth_view\n\n<\/pre>\n<p>Delete qmail email queue<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# \/usr\/local\/psa\/admin\/sbin\/mailqueuemng -D\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Is the server sending spam. Try this. http:\/\/kb.parallels.com\/766 First, check that all domains have the option \u2018Mail to non-existing user\u2019 set to \u2018reject\u2019 but not to \u2018forward.\u2019 You can change this setting to all domains using \u201cGroup Operations\u201d in the \u201cDomains\u201d tab in Parallels Plesk Control Panel. The option \u201cReject mail to nonexistent user\u201d is &#8230; <a title=\"Troubleshoot Qmail Spam\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2014\/02\/11\/troubleshoot-qmail-spam\/\" aria-label=\"Read more about Troubleshoot Qmail Spam\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[92],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-qmail"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}