I have Amazon Linux instances in AWS EC2. They run sendmail to communicate with each other, and send outgoing mail through a SMARTHOST that is a commercial email provider. No MX records are pointing to my EC2 instances' public IP addresses, and no incoming mail ports are open. What I really want is to have a commercial website (goformz.com) send a POST request with a PDF form to my website hosted on these instances whenever a user submits a form. But until they figure out how to do that, I could work with their current behavior of having them email a PDF attachment to an address on the commercial email server.

After some head-scratching, it looks like I could probably get what I need by installing fetchmail and either procmail or maildrop, no need to touch my sendmail configuration. And that it "ought" to be very simple. I am familiar with using procmail in a ~/.forward file as a user, but installing and configuring it on my EC2 servers is baffling to me after reading the documentation. It looks like both fetchmail and procmail want to run as daemons, and hand off messages to other servers. I expected that fetchmail would run as a daemon, fetching messages from the commercial email account over IMAP at some frequency, and then synchronously invoke procmail on each message, with a rule that was simply to pipe the message to a PHP script that would extract the attachment and process the form fields in it. It would be okay if the script invocation had to be in a ~/.forward file, I would hard-wire the user directory, but I don't see how to set that up. Can anyone set me straight on this, perhaps with just a pointer to documentation that would address this scenario?

I have found other answered questions that look similar, but none that have enlightened me. What I've found seems to assume that the server would be running postfix as the MTA.

  • Thanks @tripleee, I realize I'm confused and I appreciate your effort in poring through my text. I did my best to describe my problem in terms that made sense to me, but admittedly nothing was making much sense. I think I need fetchmail because my server does not accept mail from the internet - fetchmail periodically fetches mail from my commercial email provider, freeing me from configuring and maintaining an MTA that talks to the outside world. And yes, it sounds like the "-mda" option to fetchmail should work for me.
    – sootsnoot
    Commented Oct 26, 2022 at 1:59
  • 1
    So @triplee, if you would like to write this in the form of an answer, I'll mark it as the accepted answer. And if you think my reason for using fetchmail doesn't make sense, could you please elaborate a little? Tx
    – sootsnoot
    Commented Oct 26, 2022 at 2:03
  • I can't say I really understand the exposition in the first paragraph. Why are you running Sendmail at all then, or why is it relevant that you are running Sendmail if you are not going to be able to use it for anything? But for polling a single IMAP mailbox, I suppose Fetchmail is fine (though I would perhaps use something lighter, like a simple Python poller).
    – tripleee
    Commented Oct 26, 2022 at 5:16
  • If on the other hand these instances are running Sendmail to communicate with each other, it should be feasible to hook one of them up to also listen on a public IP address. A third option which comes to mind is to have AWS SES drop the incoming message into an S3 bucket and alert you, but that might be more work than it's worth if you are only running EC2 as a simple container and are not using other AWS services.
    – tripleee
    Commented Oct 26, 2022 at 5:20
  • @tripleee Instances run sendmail for outgoing mail. The web app runs on 2 instances, one for development/testing, and the other for production. The production server's sendmail is configured to use the development server as a SMARTHOST, and the development server is configured to use the commercial email provider as a SMARTHOST. So the development server's sendmail only listens for incoming connections on its private IP address, coming from their shared VPC. They are all in security groups that block incoming connections on their public IP addresses on ports other than ssh, http, and https.
    – sootsnoot
    Commented Oct 26, 2022 at 20:01

1 Answer 1


This seems rather confused. Procmail does not run as a daemon, it is invoked as the delivery agent by Fetchmail, Sendmail etc if you configured them so. The whole story about why you think need Fetchmail seems wrong, though. But the short answer to what seems to finally be your question is, just use it exactly like you expected. If it's for this single purpose, you could even configure it to run your PHP script instead of Procmail (though I doubt your PHP script is going to be robust in the face of failures, so wrapping it in Procmail is probably a good idea anyway).

I'm not very familiar with Fechmail, but IIRC you configure it to use Procmail with something like

mda "procmail /home/you/.procmailrc"

maybe you want a -d option or some other decorations, too.

Which mail server you are running is generally quite uninteresting, they all have vaguely similar mechanisms for dispatching Procmail (or another LDA) when a message is to be delivered locally. You might want to configure it to bypass the default system-wide /etc/procmailrc if the regular MTA flow should be separate from the Fetchmail one, but in your scenario, it sounds like you don't need to run Procmail from Sendmail at all, so you could keep it really simple.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .