4

I can't figure out how to configure Mailhandler with an IMAP Gmail account locally with MAMP.

I've been following the recommendation at http://drupal.org/node/207366#gmail and it is never working fine. The test mbox that ships with the module works just fine.

My settings are:

  • Protocol: IMAP
  • Folder: INBOX
  • Domain: imap.gmail.com
  • Port: 993
  • Username: [email protected]
  • Password: mypassword
  • Extra commands: /ssl

I've tested different combinations like:

  • Switch imap.gmail.com to gmail-imap.l.google.com
  • Changed port to 995 or 587
  • Trimmed username to "username" only (w/o @gmail.com)
  • Switched /ssl by /ssl/novalidate-cert, /tls, /notls...

Most of these attempts were without any conviction and only because the default config wouldn't work and return the following error when saving:

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/ssl/novalidate-cert}INBOX in MailhandlerPhpImapRetrieve->open_mailbox() (line 118 of /docroot/sites/all/modules/mailhandler/modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php).

And this error when hitting "Test connection":

Mailhandler could not access the mailbox using these settings

Any idea what I'm missing to make this work ok?

P.S. : I can ping imap.gmail.com or telnet on port 993 just fine.

2 Answers 2

1

Unfortunately, MAMP (even the Pro version) basically provides no support for G-mail. For evidence, look at the comments on the official guide on the MAMP blog.

Although I haven't tried it, one of the comments suggests this solution.

And here's another way to set up postfix on Lion without relying on MAMP.

I too use MAMP, and instead of working with mailhandler I use the SMTP module instead, which allows Drupal to send messages locally independent of the local mail configuration.

2
  • The instructions on the reality loop blog worked well for me in the past.
    – cam8001
    May 29, 2012 at 17:13
  • Thank you for the pointers. However, my issue is not to be able to send emails but to connect to a Gmail mailbox through Mailhandler so that I can convert emails into nodes. Am I missing something in your suggestion?
    – vanz
    May 30, 2012 at 8:07
1

The issue here is the "locally with MAMP." the imap_open() command is relying on the imap php library (http://www.php.net/manual/en/ref.imap.php). Which can either be compiled with or without SSL support. MAMP, and MAMP PRO do not come with an ssl imap, so, the only way to get around this and make IMAP work with SSL (which is what is required for google apps/gmail) is to compile the IMAP extension for yourself.

This (https://www.activecollab.com/forums/topic/5844/) is where I got the following information. Hopefully this is helpful:

Snow Leopard Server has PHP 5.3 built-in (hooray!), but without the IMAP module (drat!). There are several guides out there that have partial solutions to the problem, but most ask you to build your own Apache and PHP apart from the OSX native. I wanted to use as much native OSX as possible. One blog in particular was the easiest solution (with a few minor corrections in the blog comments). Here are all the instructions, in order, with all the corrections inline:

1 Open a Terminal session from OSX

2 Download and unpack the latest IMAP source code (2007f as of this writing):

cd ~/Downloads

curl -o imap.tar.gz ftp://ftp.cac.washington.edu/imap/imap-2007f.tar.gz

tar -zxvf imap.tar.gz

3 Build IMAP libraries and copy to correct locations:

cd imap-2007f/

make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"

sudo mkdir /usr/local/include (optional)

sudo cp c-client/*.h /usr/local/include/

sudo mkdir /usr/local/lib (optional)

sudo cp c-client/*.c /usr/local/lib/

sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

4 Download and unpack the source code of whatever version of PHP you are using. I was using 5.3.14

cd ~/Downloads

curl -o php.tar.gz http://us.php.net/distributions/php-5.3.14.tar.gz

tar -zxvf php.tar.gz

5 We only need the source for the IMAP extension, so there's no need to compile all of PHP.

cd php-5.3.14/ext/imap

phpize

--The following info is system dependent. I was on snow leopard so this worked for me. You might have to look this up somewhere else. MACOSX_DEPLOYMENT_TARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"

./configure --with-imap=/usr/local/imap-2007 --with-kerberos --with-imap-ssl=/usr/

6 If you received errors (specifically, a complaint about OpenSSL's evp.h), you may need to adjust the path at the end of "with-imap-ssl" to /usr/include or /usr/include/openssl. The above worked for me, using Snow Leopard 10.6.8.

7 Now make the module:

make

8 If you didn't receive an error, go to the next step. If you received an error about pcre.h (notably on MAMP instead of Snow Leopard Server), you need to copy some files from the downloaded PHP source

sudo cp ../pcre/pcrelib/pcre.h /usr/include/php/ext/pcre/

make

9 And now we copy it into our extensions directory. Your directory might be named differently, depending on what version of php you have configured.

sudo cp modules/imap.so /Applications/MAMP/bin/php/php5.3.14/lib/php/extensions/no-debug-non-zts-20090626/

10 You may have to add the following to your php.ini file, but I have a hunch that extension=imap.so is already there:

extension=/Applications/MAMP/bin/php/php5.3.14/lib/php/extensions/no-debug-non-zts-20090626/

11 Restart apache

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.