K
K
Konstantin Muzhikov2015-09-23 14:32:55
PHP
Konstantin Muzhikov, 2015-09-23 14:32:55

PHP mail client, directly or through a database?

Good afternoon, I am developing one service and there is a requirement to place an email client on it so that users can read and write letters from this service.
It turned out to read the headers and bodies of the letters, it even turned out to decode them normally, but there is one problem. All this takes a very long time (up to 10-15 seconds).
I use a set of regular PHP IMAP functions
I can assume that this time is spent on the imap_open () function.
And now the question itself is how normal mailers are made: directly with each request for a letter, they connect to the mail server, read data from there and close the connection, or read the data once and save it to the database and only occasionally check in the background whether New letter?
An example of how I read the body of the letter:

$mbox = imap_open("{" . $inputData['domain'] . ":143}INBOX", 
  $inputData['login'],
  $inputData['password']);
$body = imap_fetchbody($mbox,$msgno,1);	
$body = iconv("cp1251", "utf-8", $body);
imap_close($mbox);
return $body;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Volintsev, 2015-09-23
@GriSII

only occasionally in the background check if a new letter has arrived

yes, yes

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question