I am trying to fetch an email from outlook Inbox with the Imap package of Laravel. it is working fine with Gmail. but when I try to fetch emails from outlook it gives No message error ImapController.php
*/
public function index()
{
// dd(phpinfo());
// imap_open('{outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX', 'info@coldxpress.com.au', 'Dac67132');
$oClient = Client::account('default');
$oClient->connect();
//Get all Mailboxes
/** @var \Webklex\IMAP\Support\FolderCollection $aFolder */
$aFolder = $oClient->getFolders('INBOX.Sent');
//Loop through every Mailbox
/** @var \Webklex\IMAP\Folder $oFolder */
foreach ($aFolder as $oFolder) {
//Get all Messages of the current Mailbox $oFolder
/** @var \Webklex\IMAP\Support\MessageCollection $aMessage */
$aMessage = $oFolder->messages()->since('10.02.2020')->get();
/** @var \Webklex\IMAP\Message $oMessage */
foreach ($aMessage as $oMessage) {
echo $oMessage->getSubject() . '<br />';
// echo 'Attachments: ' . $oMessage->getAttachments()->count() . '<br />';
// echo $oMessage->getHTMLBody(true);
}
}
// return view('home');
}
Config/imap.php
'accounts' => [
'default' => [// account identifier
'host' => env('IMAP_HOST', 'outlook.office365.com'),
'port' => env('IMAP_PORT', 993),
'protocol' => env('IMAP_PROTOCOL', 'imap'), //might also use imap, [pop3 or nntp (untested)]
'encryption' => env('IMAP_ENCRYPTION', 'ssl'), // Supported: false, 'ssl', 'tls', 'notls', 'starttls'
'validate_cert' => env('IMAP_VALIDATE_CERT', false),
'username' => env('IMAP_USERNAME', 'info@coldxpress.com.au'),
'password' => env('IMAP_PASSWORD', '*********'),
],
I want to fetch Emails from Outlook account.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Hg8Vto
via IFTTT
Aucun commentaire:
Enregistrer un commentaire