danialpanah/mail-connect
Composer 安装命令:
composer require danialpanah/mail-connect
包简介
Laravel Package for Connect to Email Using IMAP
README 文档
README
Introduction
This Laravel package can open any Email Mailbox and access to its directories like inbox, sent items etc. Current version can only use the Imap protocol (PHP Imap), in the future releases using POP3 protocol will be added.
Installation
- Use following command to install:
composer require danialpanah/mail-connect
This package supports Laravel auto-discovery feature. If you are using Laravel 6.x or greater no need to do any further actions, otherwise follow below steps to add this package manually to your application.
- Add the service provider to your
providers[]array inconfig/app.phpin your laravel application:
DanialPanah\MailConnect\MailConnectServiceProvider::class
- For using Laravel Facade add the alias to your
aliases[]array inconfig/app.phpin your Laravel application:
'MailConnect': DanialPanah\MailConnect\Facades\MailConnect::class
Configuration
-
After installation, you need to add your Email settings. You can update config/mailconnect.php published file or in you Laravel .env file.
-
Run the following command to publish the configuration file:
php artisan vendor:publish --provider "DanialPanah\MailConnect\MailConnectServiceProvider"
- config/webpay.php
return [ 'email_url' => env('MAIL_CONNECT_URL', null), 'email_username' => env('MAIL_CONNECT_USERNAME', null), 'email_password' => env('MAIL_CONNECT_PASSWORD', null) ];
- Add this to
.env.exampleand.envfiles:
#Email Connect Settings
#your Imap email url e.g "{localhost:993/imap/ssl/novalidate-cert}"
MAIL_CONNECT_URL=
#your email username (could be same as your email address or any other username) e.g "me@danialrp.com"
MAIL_CONNECT_USERNAME=
#your email password
MAIL_CONNECT_USERNAME=
Usage
Following are some examples which you can use to initiate connection to your mailbox:
- Open Imap connection and access to your mailbox contents:
// Importing the class namespaces before using it
use DanialPanah\MailConnect\MailConnect;
$mailConnect = new MailConnect();
$mailConnect->protocol = 'imap'; //select protocol
$mailConnect->directory = 'inbox'; //'inbox', 'sent' etc. see allowed Imap directories.
$mailConnect->criteria = 'all'; //'all', 'seen', 'unseen' etc. see allowed Imap criteria.
$messages = $mailConnect->openMailbox(); // get mailbox messages.
// Also Could be used with PHP method chaining
$messages = $mailConnect
->protocol('imap')
->directory('inbox')
->criteria('all')
->openMailbox();
- Using Facades :
use DanialPanah\MailConnect\MailConnect;
$messages = MailConnect::openMailbox();
- Sample Response of Verify Successful Payment:
array [
0 => array:3 [
"message_number" => 18
"header" => array [
"date" => "Wed, 14 Dec 2022 14:26:44 +0000"
"subject" => "Some Subject"
"message_id" => "<B92423C93DB34E729956B11C1FE1878E1D90FC80AD1C@JOBS.360-CONSULTING.DE>"
"toaddress" => "Danial Panah <me@danialrp.com>"
"fromaddress" => "From Address <sender@email.com>"
"reply_toaddress" => "Reply To Address <sender@email.com>"
"senderaddress" => "Sender Address <sender@email.com>"
"Recent" => ""
"Unseen" => ""
"Flagged" => ""
"Answered" => ""
"Deleted" => ""
"Draft" => ""
"Msgno" => " 18"
"MailDate" => "14-Dec-2022 14:48:16 +0000"
"Size" => "11566"
"udate" => "1671029296"
]
"body" => "Html Body Message"
]
1 => array:3 [▶]
2 => array:3 [▶]
3 => array:3 [▶]
4 => array:3 [▶]
5 => array:3 [▶]
- Laravel Sample Controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DanialPanah\MailConnect\MailConnect;
class MailboxController extends Controller
{
public function MyMailbox(): View
{
$messages = $mailConnect
->protocol('imap')
->directory('inbox')
->criteria('all')
->openMailbox();
return view('emails_inbox', ['messages' => $messages]);
}
}
Support & Security
This package supports Laravel 8 or greater with PHP 8.0 and above.
- In case of discovering any issues, please create one on the Issues section.
- For contribution, fork this repo and implements your code then create a PR.
License
This repository is an open-source software under the MIT license.
ToDo
- Write tests.
- Add POP3 protocol.
danialpanah/mail-connect 适用场景与选型建议
danialpanah/mail-connect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「web service」 「php imap」 「laravel email」 「php email」 「php inbox」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 danialpanah/mail-connect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danialpanah/mail-connect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 danialpanah/mail-connect 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Model of a web-based resource
A fast and intuitive dependency injection container.
A PSR-7 compatible library for making CRUD API endpoints
Registry service.
Retrieve a WebResourceInterface instance over HTTP
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-14