Support / KnowledgeBase

 
Search the KnowledgeBase Search

Determining the source domain for emails generated from PHP scripts

  • Applies to: All (dv)

  • Difficulty: Hard

  • Time needed: 20 minutes

  • Tools needed: SSH, root access

 
  • Applies to: All (dv)
    • Difficulty: Hard
    • Time Needed: 20
    • Tools Required: SSH, root access

Overview

To determine the domain for the PHP script that is sending mail, please follow the commands below.

Instructions

  1. Create /var/qmail/bin/sendmail-wrapper script with the following content:
    #!/bin/sh
    (echo X-Additional-Header: $PWD ;cat) | tee -a /var/tmp/mail.send|/var/qmail/bin/sendmail-qmail "$@" 
  2. Create log file /var/tmp/mail.send and grant it "a+rw" rights, make the wrapper executable, rename old sendmail and link it to the new wrapper:
    touch /var/tmp/mail.send 
    chmod a+rw /var/tmp/mail.send 
    chmod a+x /var/qmail/bin/sendmail-wrapper 
    
    mv /var/qmail/bin/sendmail /var/qmail/bin/sendmail-qmail 
    ln -s /var/qmail/bin/sendmail-wrapper /var/qmail/bin/sendmail 
  3. Wait for an hour or so and revert sendmail back:

    rm -f /var/qmail/bin/sendmail
    ln -s /var/qmail/bin/sendmail-qmail /var/qmail/bin/sendmail 
  4. Examine /var/tmp/mail.send file. There should be lines starting with "X-Additional-Header:" pointing out to domain folder where the script which sent the mail is located.  The command below will provide more specific information:
    grep X-Additional /var/tmp/mail.send | grep `cat /etc/psa/psa.conf | grep HTTPD_VHOSTS_D | sed -e 's/HTTPD_VHOSTS_D//' ` 
  5. If you don't see any output from the command above, than no mail was sent using the PHP mail() function from the domains configured in Plesk.

User Comments

No visitor comments posted. Post a comment
Fields marked with an asterisk(*) are required. Comment on this article
Fill out the form below if you would like to comment on this article.
 
 
 

(code is not case-sensitive)
 
Submit
 
 

Continue