Accessing Website's Maildir


#1

I have a php script on the website that emails various individuals when an online form is filled out. Recently had problems with emails being undeliverable. I would like to monitor the contents of the maildir directory for these “undeliverable mail” response message. Right now I am accessing these files in the maildir/new directory via ftp. Is there a way to access via a mail client application? Or do you suggest going the .forward route? Does anyone have any words of wisdom or other suggestions for me?

Thanks!


#2

You could do a .forward, you could also add a “return-path” mail header, if i went that route I might do both.

If the form is generating the “FROM” address, based on the user’s email address as specified on the form, that’s likely a large part of your problem, dreamhost recently banned this form of email spoofing. Instead set up a mailbox or forward only address on one of you domains that is something like contactform@yourdreamhostdomainname.com for the “From” header, then you can then use the users supplied input as the “reply-to” address allowing who ever is answering to just hit reply.

Another approach altogether is to just abandon email for your form notifications (dreamhost’s outbound mail queues go wacky and back up all too often). Instead of using mail() just append to a file. As an example, something like:

$fp = fopen($contactformfile, "a");
fputs($fp, $now . $subject . $body );
fclose($fp);

define $contactformfile to something that includes a path to a web visible directory, and include the month and/or date in the filename, and a suffix of .txt .

Drop an .htaccess on the directory that these files are in, to restrict viewing by login, and/or IP address.

Optionally, if you want to do it even nicer, do a simple index.php for it that reads the directory and makes a clickable menu of what files are available, perhaps adding a delete button to get rid of old files. If you skip this part you can just use the servers file listing of the web visible directory. You could even add a cron to remove files after 30/60/90 days or something to keep things tidy, to me a cron to purge old is better than a delete button which can be accidentally pressed. Or maybe make a archive button to take the file out of the current listing but not trash it, then let cron clean up the archives.

If you really want to go all out with it, format the output being written to the file at .html instead and include a clickable “mailto:” link that will pre fill the to, subject and body on your local mail client when you click the link while viewing the contact form file. =]