{"id":493,"date":"2014-07-31T23:36:41","date_gmt":"2014-07-31T23:36:41","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=493"},"modified":"2014-07-31T23:36:41","modified_gmt":"2014-07-31T23:36:41","slug":"troubleshoot-qmail-spam-2","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2014\/07\/31\/troubleshoot-qmail-spam-2\/","title":{"rendered":"Troubleshoot Postfix Spam"},"content":{"rendered":"<p>RE:\u00a0<a href=\"http:\/\/kb.parallels.com\/en\/114845\" target=\"_blank\" rel=\"noopener\">http:\/\/kb.parallels.com\/en\/114845<\/a><\/p>\n<p>[stextbox id=&#8221;info&#8221;]Symptoms: Many email messages are sent from PHP scripts on the server. How can I find the domains on which these scripts are running if I am using Postfix?[\/stextbox]<\/p>\n<p>[stextbox id=&#8221;warning&#8221;]Note: \u00a0This article is for Postfix. \u00a0If you are using the Qmail mail server, see this:\u00a0<a href=\"https:\/\/qbytes.cloud\/troubleshoot-qmail-spam\/\" target=\"_blank\" rel=\"noopener\">https:\/\/qbytes.cloud\/troubleshoot-qmail-spam\/<\/a>[\/stextbox]<\/p>\n<p><strong>Resolution<\/strong><\/p>\n<p>Many email messages are sent from PHP scripts on the server. How can I find the domains on which these scripts are running?<\/p>\n<p>There is a way to determine from which folder the PHP script that sends mail was run.<\/p>\n<p>Note: Depending on your OS and Parallels Plesk Panel (Plesk) version, the paths can slightly differ from those listed below.<\/p>\n<p>Create a \/usr\/sbin\/sendmail.postfix-wrapper script with the following content:<\/p>\n<p>Create a file and open it for editing:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#touch \/usr\/sbin\/sendmail.postfix-wrapper\n#vi \/usr\/sbin\/sendmail.postfix-wrapper\n\n<\/pre>\n<p>Add the following content:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#!\/bin\/sh\n(echo X-Additional-Header: $PWD ;cat) | tee -a \/var\/tmp\/mail.send|\/usr\/sbin\/sendmail.postfix-bin &quot;$@&quot;\n\n<\/pre>\n<p>Note that this should be two lines, including #!\/bin\/sh.<\/p>\n<p>Create a log file, \/var\/tmp\/mail.send, and grant it a+rw rights. Make the wrapper executable, rename the old sendmail, and link it to the new wrapper. Then run the commands below:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">~# touch \/var\/tmp\/mail.send\n~# chmod a+rw \/var\/tmp\/mail.send\n~# chmod a+x \/usr\/sbin\/sendmail.postfix-wrapper\n~# mv \/usr\/sbin\/sendmail.postfix \/usr\/sbin\/sendmail.postfix-bin\n~# ln -s \/usr\/sbin\/sendmail.postfix-wrapper \/usr\/sbin\/sendmail.postfix\n\n<\/pre>\n<p>Wait for an hour and change the sendmail back:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">~# rm -f \/usr\/sbin\/sendmail.postfix\n~# mv \/usr\/sbin\/sendmail.postfix-bin \/usr\/sbin\/sendmail.postfix\n\n<\/pre>\n<p>Check the \/var\/tmp\/mail.send file. There should be lines starting with X-Additional-Header: pointing to the domain folders where the scripts that sent the mail are located.<\/p>\n<p>You can see all the folders from which mail PHP scripts were run with the following command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">~# grep X-Additional \/var\/tmp\/mail.send | grep `cat \/etc\/psa\/psa.conf | grep HTTPD_VHOSTS_D | sed -e &#039;s\/HTTPD_VHOSTS_D\/\/&#039; `\n\n<\/pre>\n<p>[stextbox id=&#8221;alert&#8221;]NOTE: If you see no output from the above command, it means that no mail was sent using the PHP mail() function from the Parallels Plesk Panel virtual hosts directory.[\/stextbox]<\/p>\n<p>Usually, that means one of the mail accounts has been compromised. Check login attempt count:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># zgrep -c &#039;sasl_method=LOGIN&#039; \/usr\/local\/psa\/var\/log\/maillog*\n\/usr\/local\/psa\/var\/log\/maillog:221000\n\/usr\/local\/psa\/var\/log\/maillog.processed:362327\n\/usr\/local\/psa\/var\/log\/maillog.processed.1.gz:308956\n\n<\/pre>\n<p>If you see an unusually high number of login attempts, it is very likely that accounts were compromised. You can try to identify these accounts in the following way:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># zgrep &#039;sasl_method=LOGIN&#039; \/usr\/local\/psa\/var\/log\/maillog* | awk &#039;{print $9}&#039; | sort | uniq -c | sort -nr | head\n891574 sasl_username=admin@example.com\n\n<\/pre>\n<p>To stop spam from being sent, change passwords for compromised accounts and restart the Postfix service.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RE:\u00a0http:\/\/kb.parallels.com\/en\/114845 [stextbox id=&#8221;info&#8221;]Symptoms: Many email messages are sent from PHP scripts on the server. How can I find the domains on which these scripts are running if I am using Postfix?[\/stextbox] [stextbox id=&#8221;warning&#8221;]Note: \u00a0This article is for Postfix. \u00a0If you are using the Qmail mail server, see this:\u00a0https:\/\/qbytes.cloud\/troubleshoot-qmail-spam\/[\/stextbox] Resolution Many email messages are sent from &#8230; <a title=\"Troubleshoot Postfix Spam\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2014\/07\/31\/troubleshoot-qmail-spam-2\/\" aria-label=\"Read more about Troubleshoot Postfix 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":[86,92,108],"tags":[],"class_list":["post-493","post","type-post","status-publish","format-standard","hentry","category-plesk","category-qmail","category-spam"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/493","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=493"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/493\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}