Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

Connecting to Gmail through IMAP with PHP - SSL context failed

20.543 Aufrufe
Direkt zur ersten ungelesenen Nachricht

clint....@gmail.com

ungelesen,
14.08.2009, 10:21:0114.08.09
an
I'm trying to connect to Gmail through IMAP with PHP running in
Apache. This is on an Ubuntu 9.04 system. I've got some sort of PHP
configuration issue that is keeping this from working. First, here's
what I did to setup IMAP for PHP:

sudo apt-get install libc-client2007b libc-client2007b-dev
sudo apt-get install php5-imap
sudo /etc/init.d/apache2 restart

When I run phpinfo(), I get the following imap values:

IMAP c-Client Version: 2004
SSL Support: enabled
Kerberos Support: enabled

Here's my sample code:

<?php
$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$user = 'my gmail address';
$password = 'my gmail password';

$connection = imap_open($connect_to, $user, $password)
or die("Can't connect to '$connect_to': " . imap_last_error());

imap_close($connection);
?>

When I execute this code, I get the following output:

Warning: imap_open() [function.imap-open]: Couldn't open stream
{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in /var/www/clint/
gmail/gmail.php on line 10
Can't connect to '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX':
TLS/SSL failure for imap.gmail.com: SSL context failed

Note that I can telnet to imap.gmail.com:993 from this computer. I can
also hookup Evolution (mail reader) to Gmail through IMAP and fetch
mail without problems. So, I don't think this is a firewall issue. I'm
pretty sure I've got something in PHP not setup correctly.

Any ideas?

bill

ungelesen,
14.08.2009, 15:06:2914.08.09
an

Here is what I use: (note I am using pop, not imap so the port is
995)

$in=imap_open("{pop.gmail.com:995/pop3/ssl}","my-email-address",
"my-password");
$msgs=imap_headers($in); // gets the headers from the currently
available msgs
$nummessages =count($msgs);


also on ubuntu: 9.04

clint....@gmail.com

ungelesen,
14.08.2009, 17:39:1614.08.09
an
On Aug 14, 2:06 pm, bill <nob...@spamcop.net> wrote:

Thanks for the answer, but I get the exact same error with pop as
imap. I'm sure this is some configuration error with the php on my
computer, but I'm having a hard time tracking it down. I found one
blog (http://petewarden.typepad.com/searchbrowser/2008/03/how-to-use-
imap.html) where the author posted an example of how to connect to
gmail with imap. When I run his PHP code from his web site, it works
fine. But, when I run his PHP code from my local Apache, I get the
same error I get with my stuff.

Jerry Stuckle

ungelesen,
14.08.2009, 19:34:4414.08.09
an

Do you have OpenSSL installed correctly on your local system?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

clint....@gmail.com

ungelesen,
14.08.2009, 20:45:0914.08.09
an
On Aug 14, 6:34 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Do you have OpenSSL installed correctly on your local system?

Yes. My application issues GET requests to several sites that use SSL/
HTTPS, and those work just fine. Also, if I do an "apt-get install
openssl", I get a message saying it's at the latest level.

I should mention that I didn't build PHP myself but rather installed
it with apt-get. I'm going to try building it from scratch to see if
that makes a difference.

Jerry Stuckle

ungelesen,
14.08.2009, 21:03:1314.08.09
an

It's not just what's compiled in, but what extensions you have in your
php.ini file. Just look at phpinfo() to see what's actually configured.

clint....@gmail.com

ungelesen,
16.08.2009, 10:08:4716.08.09
an
On Aug 14, 8:03 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> It's not just what's compiled in, but what extensions you have in your
> php.ini file.  Just look at phpinfo() to see what's actually configured.

When I do a phpinfo(), I get an openssl section with the following
values in it:

OpenSSL support: enabled
OpenSSL Version: OpenSSL 0.9.8g 19 Oct 2007

I don't have any extensions enabled in my php.ini file for OpenSSL.
But, from what I understand from several forum threads I've read,
OpenSSL support is automatically enabled in PHP on Ubuntu. Not sure
if that's true or not, but it does seem to match up with what phpinfo
() is showing me.

Also, my application is able to successfully perform GET operations on
HTTPS sites. So, SSL is working in general, just not for IMAP.

Jerry Stuckle

ungelesen,
16.08.2009, 15:01:1716.08.09
an

Just because it works for HTTPS does NOT mean it will work for other
things. Different operations require different requests, for instance.
And in this case the message is indicating an "SSL context failure" -
which points to OpenSSL (as opposed to, for instance, a port being
blocked). That and the fact the same code works on your server
indicates your PHP is correct. This is why I keep asking about OpenSSL.

I can think of no PHP options which would cause this specific error,
(although it still is possible). But what do you see when you compare
your local phpinfo() vs. your working phpinfo()?

And while you're at it - I'd suggest checking your openssl config
options between the two.

clint....@gmail.com

ungelesen,
16.08.2009, 15:45:0416.08.09
an
On Aug 16, 2:01 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:

I built openssl and php from scratch rather than getting them with apt-
get, and the problem went away. Everything is working now.

Thanks to everyone for the input!

luis.ssil...@gmail.com

ungelesen,
30.10.2015, 07:51:2730.10.15
an
Hi Tehere,

Did you solve this situation I got the same problem.

luis.ssil...@gmail.com

ungelesen,
30.10.2015, 07:52:3530.10.15
an
Hi there,

I got the same problem is there anyway that you solved this problem ?




On Friday, August 14, 2009 at 3:21:01 PM UTC+1, Clint....@gmail.com wrote:

ragha...@gmail.com

ungelesen,
05.02.2016, 08:52:2005.02.16
an
Hi Tehere,

Did you solve this situation I got the same problem

gwwpro...@gmail.com

ungelesen,
15.01.2020, 01:50:4715.01.20
an

kristja...@gmail.com

ungelesen,
04.03.2020, 08:43:3004.03.20
an
I don't see why people want to make things so difficult.
Could just put a link to webpage that will open their mail portal.


Kristjan Robam

Jerry Stuckle

ungelesen,
04.03.2020, 11:09:4004.03.20
an
Because that exposes their email address. Spammers look for these types
of links and when found add them to a list they sell to other spammers.

Just a great way to get inundated with SPAM.


--
==================
Remove the "x" from my email address
Jerry Stuckle
jstu...@attglobal.net
==================

Kristjan Robam

ungelesen,
04.03.2020, 15:50:2004.03.20
an
Gmail is pretty known portal.
Forgive me if I didn't get your point.
If you find gmail link, there is nothing special about this.

Kristjan Robam

Jerry Stuckle

ungelesen,
04.03.2020, 16:57:2404.03.20
an
It gives spammers a valid email address to spam - worth much more than
just a portal. And serious users don't use gmail addresses - they have
email addresses on their own domains.

Kristjan Robam

ungelesen,
04.03.2020, 16:59:5004.03.20
an
No, I didn't mean that. I mean't that you write only gmail . google . com link to your webpage. For faster access....

> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstu...@attglobal.net
> ==================

Kristjan Robam

Jerry Stuckle

ungelesen,
04.03.2020, 21:05:5104.03.20
an
> Kristjan Robam
>

That is not a valid email address and does not allow the user to send
you email.

Kristjan Robam

ungelesen,
05.03.2020, 01:35:4705.03.20
an
Yes, it allows.

> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> jstu...@attglobal.net
> ==================

Kristjan Robam

Tony Mountifield

ungelesen,
05.03.2020, 05:48:2605.03.20
an
In article <00b3f9b8-77c7-4537...@googlegroups.com>,
<kristja...@gmail.com> wrote:
> reede, 14. august 2009 17:21.01 UTC+3 kirjutas Clint....@gmail.com:
> > ...
>
> I don't see why people want to make things so difficult.
> Could just put a link to webpage that will open their mail portal.

Any particular reason you are replying to a post that is over 10 years old?

Cheers
Tony

--
Tony Mountifield
Work: to...@softins.co.uk - http://www.softins.co.uk
Play: to...@mountifield.org - http://tony.mountifield.org

Arno Welzel

ungelesen,
05.03.2020, 11:55:1005.03.20
an
On 04.03.20 17:09, Jerry Stuckle wrote:

> On 3/4/2020 8:43 AM, kristja...@gmail.com wrote:
>> reede, 14. august 2009 17:21.01 UTC+3 kirjutas Clint....@gmail.com:
[...]
>>> Note that I can telnet to imap.gmail.com:993 from this computer. I can
>>> also hookup Evolution (mail reader) to Gmail through IMAP and fetch
>>> mail without problems. So, I don't think this is a firewall issue. I'm
>>> pretty sure I've got something in PHP not setup correctly.
>>>
>>> Any ideas?
>>
>> I don't see why people want to make things so difficult.
>> Could just put a link to webpage that will open their mail portal.
>>
>>
>> Kristjan Robam
>>
>
> Because that exposes their email address. Spammers look for these types
> of links and when found add them to a list they sell to other spammers.
>
> Just a great way to get inundated with SPAM.

I think there is a lot of misunderstanding her:

What has "I can't get IMAP access to GMail working with PHP" to do with
"put a link to the mail portal"?

And what does "put a link to the mail portal" to do with "put an e-mail
address to your website"?



--
Arno Welzel
https://arnowelzel.de

Arno Welzel

ungelesen,
05.03.2020, 11:58:4005.03.20
an
You all don't understand each other!

1) The OP asked how to get IMAP ACCESS WITH PHP TO GMAIL

2) Some other guy suggested to PUT A LINK TO THE GMAIL WEBSITE INSTEAD
OF USING IMAP IN PHP ITSELF

3) And some other complained the PUTTING AN EMAIL ADDRESS ON THE WEBSITE
might be bad since spammers will collect this address

This all has NOTHING in common except that you somehow talk about "email".

Kristjan Robam

ungelesen,
06.03.2020, 01:18:5906.03.20
an
neljapäev, 5. märts 2020 12:48.26 UTC+2 kirjutas Tony Mountifield:
> In article <00b3f9b8-77c7-4537...@googlegroups.com>,
> <kristja...@gmail.com> wrote:
> > reede, 14. august 2009 17:21.01 UTC+3 kirjutas Clint....@gmail.com:
> > > ...
> >
> > I don't see why people want to make things so difficult.
> > Could just put a link to webpage that will open their mail portal.
>
> Any particular reason you are replying to a post that is over 10 years old?
>
Maybe someone can find my reply useful.

Kristjan Robam

Kristjan Robam

ungelesen,
06.03.2020, 01:20:3506.03.20
an
We just give our opinions in this topic.

Kristjan Robam

Arno Welzel

ungelesen,
06.03.2020, 03:46:1406.03.20
an
Kristjan Robam:

> neljapäev, 5. märts 2020 12:48.26 UTC+2 kirjutas Tony Mountifield:
>> In article <00b3f9b8-77c7-4537...@googlegroups.com>,
>> <kristja...@gmail.com> wrote:
>>> reede, 14. august 2009 17:21.01 UTC+3 kirjutas Clint....@gmail.com:
>>>> ...
>>>
>>> I don't see why people want to make things so difficult.
>>> Could just put a link to webpage that will open their mail portal.
>>
>> Any particular reason you are replying to a post that is over 10 years old?
>>
> Maybe someone can find my reply useful.

What is useful in this reply?

"Put a link to the webpage that will open their mail portal" is no
substitude for direct IMAP access.

For example: if you want to use IMAP to check for mails arriving on a
specific address and then process these mails by a script using a link
to the mail portal does not help.
0 neue Nachrichten