Inbound email with PHP and vpopmail

I suspect many of you – like SitePoint – use PHP to process inbound email for various purposes. For example, our warehousing / fulfillment company sends us an email with an XML attachment notifying us when an order has been shipped. It includes various useful details (shipping times, tracking numbers, freight costs, etc) that we need to store in our database.

I’ve hit problems in the past trying to shoehorn this behavior into our vpopmail installation. Vpopmail is a handy set of patches for qmail that ease the handling of large numbers of email domains and users.

The key problem is, vpopmail generally runs as the “vpopmail” user, and delivers all mail while executing under this UID. Hence any scripts it invokes do not have permission to access the PHP libraries that make our applications tick.

A lot of Googleing led me no-where, other than the questionable option of making all our PHP libraries world-readable. No thanks!

I discovered that our best bet was to create a local domain to have the relevant emails delivered to. In a vpopmail installation, local domains behave just like regular qmail domains rather than vpopmail’s “virtual domain” approach.

e.g [email protected]

where “processing.sitepoint.com” is setup as a local domain.

Setting up a local domain is simple; just add it to /var/qmail/control/locals (and don’t forget to put it in rcpthosts, too). Then -HUP qmail-send and you’re good to go.

Once this is done, emails to [email protected] are delivered to the UNIX system account “someuser”. And most importantly it is delivered under that users’ UID/GID.

Thus the script that processes these emails now executes as “someuser” which presumably has access the relevant libraries, and can get the job done.

Replay

Category: programming Time: 2005-06-24 Views: 0
Tags:

Related post

  • Sending Emails with PHP 2011-10-21

    We know why you're here- you want to write a script to send emails to your friends with funny return addresses. I'm here to tell you you're better than that. There's so much more you could be doing with your life! But, what other reasons could you po

  • PHPMaster: Sending Emails with PHP 2011-10-23

    We know why you're here- you want to write a script to send emails to your friends with funny return addresses. I'm here to tell you you're better than that. There's so much more you could be doing with your life! But, what other reasons could you po

  • Mail header to answer to a email with php 2016-02-10

    My goal is to anwer to a mail to a email that is in a inbox of a mailbox. I am at the point that I can read the mail out of the mailbox and I can send emails. The only thing is that I would like it for the receiver of the email that all the conversat

  • Uploading with PHP and suPHP 2012-02-07

    I've setup ISPconfig on apache2+php5-cgi+suPHP. One of the users had Joomla installed and when that use upload pictures they get created with 600 permissions. In this case apache can't read them back. I though that would be in /etc/suphp.conf but my

  • Creating Web Services with PHP and SOAP, Part 1 2012-02-20

    Creating Web Services with PHP and SOAP Creating Web Services with PHP and SOAP, Part 1 Creating Web Services with PHP and SOAP, Part 2 As application developers, the ability to develop software and services for a wide range of platforms is a necessa

  • Creating Web Services with PHP and SOAP, Part 2 2012-02-27

    Creating Web Services with PHP and SOAP Creating Web Services with PHP and SOAP, Part 1 Creating Web Services with PHP and SOAP, Part 2 In the first part of this series, I showed you how developing applications with the SOAP protocol is a great way t

  • Reference materials for learning Google API V3 with PHP and MySQL (tracking) 2012-07-18

    I am new to this Google API. Now i wanted to learn Google API with PHP and MySQL. Actually i wanted to create an application that will track x,y coordinates coordinates on real time bases for android mobile. There will be many Android mobiles which w

  • All-purposes AJAX handler made with PHP and .htaccess that speaks JSON - Part 2 2015-02-11

    Earlier, I've posted a question about a file used to handle AJAX requests. I've followed some of the advices given and made some changes on the code itself. You can go on "All-purposes AJAX handler made with PHP and .htaccess that speaks JSON" t

  • implement geo / spatial / proximity search with php and mysql - what have you done successfully 2016-02-01

    For my website's users, I want to implement a worldwide geo / spatial / proximity search with php and mysql. I want to do this as simply and minimally as possible. What is the minimum data I should capture (Country, State, City, Postal Code, etc.)? T

  • Python email (with txt and html) 2016-02-10

    I'm trying to send and email with html and txt. But I need the contents of the .txt file into the email html body. And so far I can only get the txt file to work or the html, but not both. Any ideas? import smtplib from email.MIMEMultipart import MIM

  • Build your own Web Service with PHP and XML-RPC 2002-07-16

    One of the Internet's current hot topics is Web Services, introduced by Kevin Yank in his article Web Services Demystified. If you've been following industry news on the subject, you may think this is some high level technology, of interest only to b

  • Instant XML with PHP and PEAR::XML_Serializer 2004-05-17

    These days, XML has become part of landscape in most all areas of software development - none more so than on the Web. Those using common XML applications, such as RSS and XML-RPC, will probably find public domain libraries geared specifically to hel

  • Multi-Factor Authentication with PHP and Twilio 2012-06-22

    There are various approaches used to confirm people are in fact who they say they: reference some aspect of the user herself (e.g. biometrics), ask for something the user knows (e.g. a password), or ask for something the user physically has (e.g. an

  • how secure is this way of writing and reading with PHP and SQLite? 2013-04-12

    This is a security question. I'm quite new to PHP and just a beginner in SQLite. For practical, and educational reasons, I'm writing a small PHP site that will serve as one-threaded discussion (meaning, only one topic / no topics) between me and my f

  • Digital Tickets with PHP and Apple Passbook 2013-05-29

    Why should we PHP warriors care at all about Apple's Passbook? Well first because Apple made this technology open (well, sort of-), second because it can be used outside iOS devices, and third because it involves a lot of well-known and loved technol

  • Sending Confirmation Emails with Phalcon and Swift 2014-01-27

    Today, sending emails is considered the basic functionality of any web application. Usually, an email is sent to notify the user of some kind of activity that has taken place on the website, such as when he registers the account, updates information,

  • Fedora 10 Server: Sending emails with php scripts 2014-06-01

    Hello, What do I need to enable on my fedora 10 server so that I can send emails with a simple PHP mail script? I have already opened PORT 25. Thank you, Bryan Andrade --------------Solutions------------- PHP's mail() function should work out of the

  • PHP Email Form: PHP and HTML seems to check out, but doesn't send 2014-07-09

    <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: yoursite.com'; $to = '[email protected]'; $subject = 'Customer Inquiry'; $body = "From: $name\n E-Mail: $email\n Message:\n $message"; if

  • Send an email with PHP using postfix from a local server to any email address 2015-09-15

    I have created a webpage on my localhost and there is a text box for the user to fill out with her/him email address and there is a Send Email button. When the button is pressed an email with a content of Hello is sent to the provided email address.

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 1.614 (s). 13 q(s)