Connect to Gmail with PHP & IMAP

前端 未结 3 2132
轮回少年
轮回少年 2020-12-29 10:31

I have enabled OpenSSL and IMAP functions from my php.ini file and phpinfo() confirms it.

By using the code below

相关标签:
3条回答
  • 2020-12-29 11:06

    UPDATE:

    After searching for my problem on the Internet, i did not found a solution that solves my problem completely. Although if

    1) I use the insecure $connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';

    2)And allow gmail to be accessed by less secured apps,

    solves my problem for now.

    Please check this https://support.google.com/accounts/answer/6010255?hl=en

    0 讨论(0)
  • 2020-12-29 11:08

    First check your date and time settings on your server are correct.

    Alternatively try:

    $connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX',
    

    This will stop it from trying to validate certificate.

    I will probably get downvotes from people telling me this is bad practice as this leaves you open to Man in the Middle attacks. Which is true.

    0 讨论(0)
  • 2020-12-29 11:24

    If you get blocked, this can be because google sees a login from a new device.

    Go to your google account and check https://myaccount.google.com/device-activity and let them know the 'Unknown device is ok to use'.

    0 讨论(0)
提交回复
热议问题