Hướng dẫn php imap get all emails - php imap nhận tất cả email

Tôi đang cố gắng tìm nạp bất kỳ email nào nhận được và gửi, và viết nó vào cơ sở dữ liệu MySQL bằng PHP.

Tên máy chủ tôi đang sử dụng là:

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';

Đó chỉ tham khảo hộp thư đến và lấy thành công chỉ nhận được email nhận được.

Để lấy email được gửi, tôi đang cố gắng sử dụng tên máy chủ này:

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';

Bằng cách thay thế "Hộp thư đến" bằng "[Gmail]/All Mail", không có email (thậm chí không được gửi) và được trả lại.

Làm cách nào để lấy tất cả các email được gửi và nhận?

Hỏi ngày 10 tháng 12 năm 2013 lúc 16:38Dec 10, 2013 at 16:38

Hướng dẫn php imap get all emails - php imap nhận tất cả email

Bạn có thể sử dụng mã này

$host = '{imap.gmail.com:993/ssl}';
$mail_con = imap_open($host, $login, $password);
$mailboxes = imap_list($mail_con, $host, '*');

Bạn có thể nhận được mảng như thế này

Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)

Xóa mã trên và sử dụng bất kỳ mảng nào trong imap_open như thế này

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);

Đã trả lời ngày 16 tháng 3 năm 2017 lúc 6:21Mar 16, 2017 at 6:21

Hướng dẫn php imap get all emails - php imap nhận tất cả email

Bạn có thể cần phải làm điều này trong hai cuộc gọi, hộp thư đến và gửi các mục. Theo bài đăng này: thư mục Gmail đã gửi không thể truy cập bằng IMAP, thư mục các mục đã gửi được gọi là [gmail]/sent mail

Đã trả lời ngày 10 tháng 12 năm 2013 lúc 16:46Dec 10, 2013 at 16:46

Hướng dẫn php imap get all emails - php imap nhận tất cả email

Tên cướpRobbert

6.4665 Huy hiệu vàng34 Huy hiệu bạc61 Huy hiệu Đồng5 gold badges34 silver badges61 bronze badges

Trên thực tế, điều này rất đơn giản để lấy thư từ tất cả các thư mục này, những gì bạn phải làm chỉ là tạo một phần mở rộng thư mục như .Sent, .drafts, v.v.

Example:

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created

Hướng dẫn php imap get all emails - php imap nhận tất cả email

Bhargav Rao

47.8K27 Huy hiệu vàng123 Huy hiệu bạc138 Huy hiệu Đồng27 gold badges123 silver badges138 bronze badges

Đã trả lời ngày 20 tháng 12 năm 2014 lúc 4:35Dec 20, 2014 at 4:35

Hướng dẫn php imap get all emails - php imap nhận tất cả email

(Php 4, Php 5, Php 7, Php 8)

IMAP_FETCH_OVERVIEW - Đọc tổng quan về thông tin trong các tiêu đề của tin nhắn đã choRead an overview of the information in the headers of the given message

Sự mô tả

IMAP_FETCH_OVERVIEW (IMAP \ Connection $imap, String $sequence, int $flags = 0): mảng | Sai(IMAP\Connection $imap, string $sequence, int $flags = 0): array|false

Thông số

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
0

Một thể hiện IMAP \ kết nối.IMAP\Connection instance.

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
1

Một mô tả trình tự tin nhắn. Bạn có thể liệt kê các tin nhắn mong muốn với cú pháp

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
2 hoặc truy xuất tất cả các tin nhắn trong một khoảng thời gian với cú pháp
$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
3

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
4

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
1 sẽ chứa một chuỗi các chỉ số tin nhắn hoặc UID, nếu tham số này được đặt thành
$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
6.
$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
6
.

Trả về giá trị

Trả về một mảng các đối tượng mô tả một tiêu đề tin nhắn. Đối tượng sẽ chỉ xác định một thuộc tính nếu nó tồn tại. Các thuộc tính có thể là:

  • $hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
    
    7 - Chủ đề tin nhắn
  • $hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
    
    8 - Ai đã gửi nó
  • $hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
    
    9 - người nhận
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    0 - Nó được gửi khi nào
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    1 - id tin nhắn
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    2 - là tham chiếu đến ID tin nhắn này
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    3 - là câu trả lời cho ID tin nhắn này
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    4 - Kích thước trong byte
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    5 - uid tin nhắn có trong hộp thư
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    6 - Số thứ tự tin nhắn trong hộp thư
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    7 - ​​Thông báo này được gắn cờ như gần đây
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    8 - Thông báo này được gắn cờ
  • $host = '{imap.gmail.com:993/ssl}';
    $mail_con = imap_open($host, $login, $password);
    $mailboxes = imap_list($mail_con, $host, '*');
    
    9 - Thông báo này được gắn cờ là đã trả lời
  • Array(
        [0] => {imap.gmail.com:993/ssl}INBOX
        [1] => {imap.gmail.com:993/ssl}Personal
        [2] => {imap.gmail.com:993/ssl}Servers
        [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
        [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
    )
    
    0 - Thông báo này được gắn cờ để xóa
  • Array(
        [0] => {imap.gmail.com:993/ssl}INBOX
        [1] => {imap.gmail.com:993/ssl}Personal
        [2] => {imap.gmail.com:993/ssl}Servers
        [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
        [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
    )
    
    1 - Thông báo này được gắn cờ như đã đọc
  • Array(
        [0] => {imap.gmail.com:993/ssl}INBOX
        [1] => {imap.gmail.com:993/ssl}Personal
        [2] => {imap.gmail.com:993/ssl}Servers
        [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
        [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
    )
    
    2 - Thông điệp này được gắn cờ là một bản nháp
  • Array(
        [0] => {imap.gmail.com:993/ssl}INBOX
        [1] => {imap.gmail.com:993/ssl}Personal
        [2] => {imap.gmail.com:993/ssl}Servers
        [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
        [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
    )
    
    3 - Thời gian unix của ngày đến

Hàm trả về

Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)
4 khi thất bại.
Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)
4
on failure.

Thay đổi

Phiên bảnSự mô tả
8.1.0 Tham số
$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
0 mong đợi một thể hiện IMAP \ kết nối ngay bây giờ; Trước đây, một tài nguyên đã được dự kiến.IMAP\Connection instance now; previously, a resource was expected.

Ví dụ

Ví dụ #1 IMAP_Fetch_Overview () Ví dụimap_fetch_overview() example

Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)
6

Raja tại Aonic Dot Net

15 năm trước

Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)
7

Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)
8

Array(
    [0] => {imap.gmail.com:993/ssl}INBOX
    [1] => {imap.gmail.com:993/ssl}Personal
    [2] => {imap.gmail.com:993/ssl}Servers
    [3] => {imap.ipage.com:993/imap/ssl}INBOX.Sent Items
    [4] => {imap.ipage.com:993/imap/ssl}INBOX.Drafts
)
9

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
0

Nitơ ¶

7 năm trước

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
1

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
2

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
3

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Thư tại Slueoend Dot ch ¶

18 năm trước

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
5

Thinice tại gmail dot com

11 năm trước

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
6

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
7

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
8

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
9

Steve tại Stevenchalker Dot Net

21 năm trước

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
0

Damien tại dipisoft dot com ¶

1 năm trước

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
1

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
2

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Ap.muthu ¶

7 năm trước

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
4

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
5

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
6

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Thư tại Slueoend Dot ch ¶

18 năm trước

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
8

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Sent'; //For Sent Items
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Drafts';//For draft
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Trash';//For trash
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.Junk';//For junk
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX.yourfolder';//For the folders u created
9

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Thinice tại gmail dot com

11 năm trước

[gmail]/sent mail1

Steve tại Stevenchalker Dot Net

21 năm trước

[gmail]/sent mail2

[gmail]/sent mail3

[gmail]/sent mail4

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Damien tại dipisoft dot com ¶

18 năm trước

[gmail]/sent mail6

[gmail]/sent mail7

[gmail]/sent mail8

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Thinice tại gmail dot com

11 năm trước

$imap0

$imap1

$imap2

$imap3

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Steve tại Stevenchalker Dot Net

11 năm trước

$imap5

$imap6

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Steve tại Stevenchalker Dot Net

18 năm trước

$imap8

$imap9

$sequence0

$sequence1

$sequence2

$sequence0

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Thinice tại gmail dot com

11 năm trước

$sequence5

$sequence6

$sequence7

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Steve tại Stevenchalker Dot Net

21 năm trước

$sequence9

$flags0

$flags1

$flags2

$flags3

$flags4

$flags5

Damien tại dipisoft dot com ¶

15 năm trước

$flags6

$flags7

$flags8

$flags9

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
00

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
01

 $host = '{imap.gmail.com:993/ssl}INBOX.Sent';
 $mail_con = imap_open($host, $login, $password);
4

Nitơ ¶

7 năm trước

$hostname = '{imap.gmail.com:993/imap/ssl}[Gmail]/All Mail';
03

Làm thế nào tôi có thể nhận được email trong PHP?

Có thể nhận email trong PHP bằng cách chạy một máy chủ thư và thực hiện tập lệnh PHP với email được chuyển cho Stdin. Với CloudMailin, bạn không cần phải làm bất cứ điều gì, email của bạn được gửi đến ứng dụng của bạn qua (các) HTTP.running a mail server and executing a PHP script with the email passed to STDIN. With CloudMailin you don't need to do any of that, your email is delivered to your application over HTTP(S).

IMAP trong PHP là gì?

IMAP là viết tắt của Giao thức truy cập thư Internet, chức năng PHP-IMAP giúp bạn truy cập tài khoản email và tìm nạp email từ chúng.Sử dụng các chức năng này, bạn cũng có thể làm việc với NNTP, giao thức POP3 và các phương thức truy cập hộp thư cục bộ.Với sự trợ giúp của thư viện này, bạn có thể tạo các ứng dụng web xử lý email của bạn.Internet Mail Access Protocol, PHP-IMAP functions helps you to access an email account and fetch emails from them. Using these functions you can also work with NNTP, POP3 protocols and local mailbox access methods. With the help of this library you can create web applications that handle your emails.

Làm thế nào để kết nối Gmail trong IMAP PHP?

Cấu hình IMAP trong môi trường PHP và Gmail..
Cài đặt thư viện PHP IMAP.....
Bật tiện ích mở rộng thư viện IMAP trong tệp cấu hình PHP xóa dấu chấm phẩy (;) ở đầu dòng.....
Tăng giới hạn cho Chỉ thị MAX_EXECATION_TIME trong tệp php.ini ..
Khởi động lại Apache để làm cho những thay đổi này hiệu quả ..

IMAP ở Laravel là gì?

Laravel IMAP là một cách dễ dàng để tích hợp cả mô-đun Php-Imap gốc và giao thức IMAP tùy chỉnh mở rộng vào ứng dụng Laravel của bạn.Điều này cho phép ứng dụng của bạn không chỉ trả lời các email mới mà còn cho phép nó đọc và phân tích các thư hiện có và nhiều hơn nữa.an easy way to integrate both the native php-imap module and an extended custom imap protocol into your Laravel app. This enables your app to not only respond to new emails but also allows it to read and parse existing mails and much more.