PHP code example of afinogen89 / get-mail
1. Go to this page and download the library: Download afinogen89/get-mail library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
afinogen89 / get-mail example snippets
$pop3 = new afinogen89\getmail\protocol\Pop3('example.ru');
$pop3->login('[email protected] ', '123456');
$msgList = $pop3->getList();
$pop3->logout();
$storage = new afinogen89\getmail\storage\Pop3(['host' => 'example.ru', 'user' => '[email protected] ', 'password' => '123456']);
$msg = $storage->getMessage(1);
$msg->saveToFile('/tmp/1.eml');
echo $msg->getHeaders()->getSubject();
foreach($msg->getParts() as $part) {
echo $part->getContentDecode().PHP_EOL;
}
foreach($msg->getAttachments() as $t) {
$t->saveToFile('/tmp/' . $t->filename);
}
$storage = new afinogen89\getmail\storage\File(['path' => '../email/']);
$msg = $storage->getMessage(1);
$msg->saveToFile('/tmp/1.eml');
echo $msg->getHeaders()->getSubject();
$storage = new afinogen89\getmail\storage\Pop3(['host' => 'pop.gmail.com', 'user' => '[email protected] ', 'password' => 'pass', 'ssl' => 'SSL']);
$storage = afinogen89\getmail\storage\Storage::init(
[
'storage' => \afinogen89\getmail\storage\Storage::POP3,
'host' => 'pop.gmail.com',
'user' => '[email protected] ',
'password' => '123456',
'ssl' => 'SSL'
]
);
$storage = new \afinogen89\getmail\storage\Pop3(
[
'host' => 'pop.yandex.ru',
'user' => '[email protected] ',
'password' => '123456',
'ssl' => 'SSL'
]
);
$pop3 = new afinogen89\getmail\protocol\Pop3('example.ru');
$pop3->login('[email protected] ', '123456');
$msgList = $pop3->getList();
$pop3->logout();
$storage = new afinogen89\getmail\storage\Pop3(['host' => 'example.ru', 'user' => '[email protected] ', 'password' => '123456']);
$msg = $storage->getMessage(1);
$msg->saveToFile('/tmp/1.eml');
echo $msg->getHeaders()->getSubject();
foreach($msg->getParts() as $part) {
echo $part->getContentDecode().PHP_EOL;
}
foreach($msg->getAttachments() as $t) {
$t->saveToFile('/tmp/' . $t->filename);
}