Answer the question
In order to leave comments, you need to log in
How to receive emails in php?
Hello everyone) You need to create a mail server in which you can programmatically create accounts (mailboxes) from php, receive letters on them and parse them.
And so that you can set up a hook - when a letter arrives, a script would be called.
How to do this? In which direction to dig? Server on ubuntu.
Answer the question
In order to leave comments, you need to log in
Well, in PHP, starting from some version, you can create sockets and listen for incoming connections, so you can write your own mail server that accepts letters and allows you to check) Another thing - is it necessary?)
And so that you can set up a hook - when a letter arrives, a script would be called.Read the documentation for services that provide such services.
Isn't it easier to use VPS and raise your mail server?
Boxes can be stored in the database and created accordingly from php
. Letters themselves can also be stored in the database, and run a php script by cron and make the necessary selection even by regexp.
Postfix + dbmail will handle this.
Set up a mail server, in the settings of the mail server you make a command call upon the arrival of a letter (how exactly it depends on the server used, this is another question). And what kind of command it will be - it's up to you to decide whether you make a call to the php file if necessary, or an HTTP request somewhere, or something else.
Look at iRedMail, after installation you have a mail server, a database with accounts, letters in some format in the Dovecot file system stores (google in which one if necessary, I don’t remember offhand, I’m too lazy to search). It remains to dig into the graphic panel to figure out how to create arbitrary accounts yourself directly and pull out what you need.
Thus you have:
The task is not completely clear. Why do you need to create mailboxes and parse letters from there? If this is not a service for people, but you just need to make dummy boxes, then it's easier to set up an email alias system so that letters actually fall into one real box.
Or even set up a mail server so that all letters to non-existent emails in the domain fall where you need.
I think it will be easier to implement than what you originally intended.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question