/    Sign up×
Community /Pin to ProfileBookmark

imap_open reading sent emails

I’m connecting to gMail using imap function. I can successfully read the INBOX mails, however, I cannot retrieve the sent mails.

[CODE]
$hostname = ‘{imap.gmail.com:}INBOX’;
$username = ‘[email protected]’;
$password = ‘mypassword’;

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die(‘Cannot connect to Gmail: ‘ . imap_last_error());

$emails = imap_search($inbox,’ALL’);

if($emails) {

foreach($emails as $email_number) {

$overview = imap_fetch_overview($inbox,$email_number,0);
$message = imap_fetchbody($inbox,$email_number,2);
$header = imap_header($inbox, $email_number); // get first mails header

…. output here…..

[/CODE]

The above works perfect for inbox. However, if I try to read the sent mail by changing the hostname with the sent mail folder (as below), it doesn’t work.

$hostname = ‘{imap.gmail.com}[Gmail]/Sent Mail
‘;

Does anyone know how to use imap functions to read sent mail in gMail?

I will need toaddress, date, subject and body fields for each sent mail.

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @waMP spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...