在php-imap中从bluemix加速gmail


Accesing gmail from bluemix in php imap

我正试图在bluemix应用程序中使用php-imp从gmail帐户获取邮件。我认为这是一个bluemix配置问题。

我已经在gmail帐户中启用了imap。

在bluemix中,我添加了一个文件.user.ini,并写道:extension=php_imap.dll

php代码为:

<?p
    hp
     set_time_limit(60); 
     /* connect to gmail with your credentials */
    $hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
    $username = 'mygmailaccount@gmail.com';  
    $password = 'mypassword';
    /* try to connect */
    print_r('debug: just before accessing gmail');
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
    print_r('debug: i did not die when accesing gmail ');
    /*here is more code but I do not access this...  */
    ?>

当我运行这段代码时,我会得到第一条调试消息,仅此而已。没有错误或其他调试。

我可能猜测imap.dll设置有问题。

我能对此提出建议吗?:)

在应用程序根目录中创建以下目录和文件(如果不存在):

.bp-config/options.json

options.json文件应包含以下内容:

{
   "PHP_EXTENSIONS": ["imap"]
}

使用再次推送您的应用程序

cf push

确保你的谷歌帐户中启用了IMAP,并在下面的每个链接中打开对不太安全的应用程序的访问:

https://support.google.com/accounts/answer/6010255

免责声明:谷歌不建议打开对不太安全的应用程序的访问。