M
M
Maxim Koreev2017-02-28 13:24:42
PHP
Maxim Koreev, 2017-02-28 13:24:42

How to receive and process files by e-mail?

It is necessary to process letters with attachments coming to a specific address, i.e. configure the mail server so that it saves the attachment to a specific location and calls my php script with the parameters "from", "subject" and "attached file". In which direction to dig, what to twist? I'm not a specialist in nix administration, but I can read man, if anything.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
chupasaurus, 2017-02-28
@chupasaurus

sendmail (which is an MTA, not a PHP script) can call scripts as a "delivery" of incoming messages, passing the entire set of SMTP fields and their data to stdin, i.e. it is enough to write a parser; Another option is to write a letter parser (there is no built-in parameter for issuing an attachment) in the language of sendmail itself, but you are more likely to invoke half of Hell while doing this, writing an SMTP letter parser is easier and faster to google.

A
Alexander Chernykh, 2017-02-28
@sashkets

You didn't specify OS and mailer.
But if this is something from the Unix world, then procmail is attached to sendmail/exim/postfix. It filters, adds, executes scripts. Doesn't work with virtual accounts

M
Maxim Koreev, 2017-02-28
@MAXiDROME

I did it like this: https://habrahabr.ru/post/126448/
Only instead of robot: "|php -q /path/to/script.php" I have robot: "|cd /path/to/script && php - q script.php" and get the error Diagnostic-Code: x-unix; sh: 1: cd: can't cd to /path/to/script
Looks like you're missing permissions for the postfix user? How to add them so as not to break anything? The rights to the directory are 755, on the level above - 750, maybe this is the case?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question