<?php $hostname = ‘{imap.gmail.com:993/imap/ssl}’; $username = ‘xxx@gmail.com’; $password = ‘pass’; $inbox = imap_open($hostname,$username,$password); $nums=imap_num_msg($inbox); echo $nums; ?>
I want to read how many emails in my gmail ,but failed,the code can’t executed from my vps in digitalocean. The error info is : imap_open(): Couldn’t open stream . A friend tell me that the code is right to read email numbers in gmail ,maybe is the firefox problem. Many web hosts block mail ports by default.
Which port will be opened when to get the email from gmail?How to check which status my port are in my digitalocean vps? Does my digitalocean vps block the port ?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
We don’t block any incoming mail ports. Doing some searching, this blog post may be useful in fetching gmail messages.
This stackoverflow question outlines how to retrieve message bodies via php-imap.
To get the subject I would recommend replacing the imap_fetchbody call for an imap_fetch_overview call which includes the subject and basic header details.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.