Skip to content

Instantly share code, notes, and snippets.

@mavci
Created December 10, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mavci/01576490784aee64a1bd to your computer and use it in GitHub Desktop.
Save mavci/01576490784aee64a1bd to your computer and use it in GitHub Desktop.
IMAP Example (Laravel)
$mailbox = new PhpImap\Mailbox('{imap.yandex.com.tr:993/imap/ssl}INBOX', 'mail@mail.com', '******', __DIR__);
$mails = array();
$mailsIds = $mailbox->searchMailBox('UNSEEN');
if( ! $mailsIds)
die('Mailbox is empty');
foreach ($mailsIds as $mail_id)
{
$mail = $mailbox->getMail($mail_id);
$subject = $mail->subject;
$name = $mail->fromName;
$email = $mail->fromAddress;
$attachments = $mail->getAttachments();
foreach ($attachments as $attachment)
{
$mail = File::get($attachment->filePath);
break;
}
Mail::raw('Mailiniz bize ulaştı ' . $mail, function($message) use ($email)
{
$message->to($email)->subject('Cevap maili');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment