Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Diode

macrumors 68020
Original poster
Just came across this cool piece of software:


z-push


Unfortunately this requires some extensive knowledge in php, linux, and Apache but if your comfortable it will work just fine. I've had it running for the past day and get instant notification of all emails.

Replies work great as well as it can be configured to use the default gmail smtp server.

To install on debian do the following:
Code:
> apt-get install apache2
> apt-get install php5
> apt-get install php5-imap
>apt-get install subversion
>cd /var/www/
>svn co svn://svn.berlios.de/z-push/trunk ./z-push



> nano /var/www/z-push/config.php

Change the settings to...

$BACKEND_PROVIDER = "BackendIMAP";
define('IMAP_SERVER', 'imap.gmail.com');
define('IMAP_PORT', 993);
define('IMAP_OPTIONS', '/notls/norsh/ssl');

> chmod 777 /var/www/z-push/state
> chmod 755 /var/www/z-push/state
> chown www-data:www-data /var/www/z-push/state

> nano /etc/apache2/httpd.conf

Add the following...

Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php
php_flag magic_quotes_gpc off
php_flag register_globals off
php_flag magic_quotes_runtime off
php_flag short_open_tag on

> touch /var/www/z-push/debug.txt
> chmod 777 /var/www/z-push/debug.txt

> sudo apt-get install php5-pear
> sudo pear install --alldeps Mail
> sudo aptitude install esmtp

> nano /etc/esmtprc

Change the settings to...

hostname smtp.gmail.com:587
username "username@gmail.com"
password "password"
starttls required
mda "/usr/bin/procmail -d %T"

> nano /etc/php5/apache2/php.ini

Change the settings to...

sendmail_path="/usr/bin/esmtp -t -i"

> mkdir ~/.authenticate
> chmod 0700 ~/.authenticate
> sudo aptitude install ca-certificates
> cp -a /etc/ssl/certs/ ~/.authenticate/ca
> chmod -R go-rwx ~/.authenticate/ca


> sudo apt-get install ssl-cert
> mkdir /etc/apache2/ssl
> make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
> a2enmod ssl
> cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl

> nano /etc/apache2/sites-available/ssl

Modify the start so it looks something like this...

NameVirtualHost *:443
<virtualhost *:443>
ServerAdmin webmaster@localhost

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem

> nano /etc/apache2/sites-available/default

Modify the start so it looks something like this...

NameVirtualHost *:80
<virtualhost *:80>

> sudo a2ensite ssl

> nano /etc/apache2/ports.conf

Add the following line to it...

Listen 443

> /etc/init.d/apache2 reload

To test whether
your Apache setup is working correctly, you can simply type the Z-Push URL
in your browser, to see if apache is correctly redirecting your request to
z-push. You can simply use:

http://<serverip>/Microsoft-Server-ActiveSync

If correctly configured, you should see a username/password request, and
when you specify a valid username & password, you should see a string like

"Your device requested the Z-Push URL without the required GET parameters"

If not, then check your PHP and Apache settings.

Finally open your iphone and do the following:

Settings->Email->Add Account->Exchange

Email: account@gmail.com
Username: none\account@gmail.com
Password: gmail password

A popup will tell you it can validate.  Hit cancel and it should ask for a server address ... enter your IP address/host name

Another pop-up will say it can't validate the certificate.  Hit OK.

I'm sure something similiar could be installed on a mac server but I'm not sure if it would work (Although I don't see why not)

This will at least tie me over until either gmail releases push or a more commercialized solution surfaces.

You can find cheap VPS hosts with debian for 5~7/month that will run this just fine.
 
Intriguing idea, but if I were to do this myself I would definitely go with a hosted server as you suggested. I wouldn't want my iphone to suddenly stop getting notices about my gmail inbox if my server at home became inaccessible due to an extended power outage (UPS' can only last for so long) or if my cable modem went flaky.
 
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_0_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5C1 Safari/525.20)

yep look at the forums. Lots of iPhone users.

Still not perfect as switching to wifi kills the connection but I leave it off and just use 3G
 
Cool, I'll see if my friend will let me install this on his server. What do you mean that wifi kills the connection? Does that mean that I won't get push notifications while wifi is on but that it will start working once wifi is disabled? I only turn wifi on if I'm going to be using Safari or an app that needs the internet, rest of the time it's off.
 
Cool, I'll see if my friend will let me install this on his server. What do you mean that wifi kills the connection? Does that mean that I won't get push notifications while wifi is on but that it will start working once wifi is disabled? I only turn wifi on if I'm going to be using Safari or an app that needs the internet, rest of the time it's off.

Look at the forums but I believe wifi won't do push or something for some unknown reason. I don't use wifi so I don't know.
 
It still seems like the phone would be connected on the 3G network and would receive notifications that way. I guess I'll look into it
 
google

With all the money and power google has they really need to get off their buts and implement this as a standard. I've been loving my gmail for a long time but use my yahoo one more now at least for important stuff because of push.
 
And if you have a CentOS server.

> yum install apache2
> yum install php
> yum install php-imap
> yum install subversion
> cd /var/www/
> svn co svn://svn.berlios.de/z-push/trunk ./z-push
> nano /var/www/z-push/config.php

Change the settings to...

$BACKEND_PROVIDER = "BackendIMAP";
define('IMAP_SERVER', 'imap.gmail.com');
define('IMAP_PORT', 993);
define('IMAP_OPTIONS', '/notls/norsh/ssl');

> chmod 777 /var/www/z-push/state
> chown apache.apache /var/www/z-push/state

> nano /etc/httpd/conf/httpd.conf

Add the following...

Alias /Microsoft-Server-ActiveSync /var/www/z-push/index.php
php_flag magic_quotes_gpc off
php_flag register_globals off
php_flag magic_quotes_runtime off
php_flag short_open_tag on

> touch /var/www/z-push/debug.txt
> chmod 777 /var/www/z-push/debug.txt

> yum install php-pear
> pear install --alldeps Mail

> nano /etc/esmtprc

Change the settings to...

hostname smtp.gmail.com:587
username "username@gmail.com"
password "password"
starttls required
mda "/usr/bin/procmail -d %T"

> nano /etc/php5/apache2/php.ini

Change the settings to...

sendmail_path="/usr/bin/esmtp -t -i"

> Setup the SSL stuff for apache.

yum install mod_ssl openssl

> Generate private key
openssl genrsa -out ca.key 1024

> Generate CSR
openssl req -new -key ca.key -out ca.csr

> Generate Self Signed Key
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

> Move the files to the correct locations
mv ca.crt /etc/pki/tls/certs
mv ca.key /etc/pki/tls/private/ca.key
mv ca.csr /etc/pki/tls/private/ca.csr

> Then we need to update the Apache SSL configuration file
nano /etc/httpd/conf.d/ssl.conf
> Change the paths to match where the Key file is stored. If you've used the method above it will be
SSLCertificateFile /etc/pki/tls/certs/ca.crt
> Then set the correct path for the Certificate Key File a few lines below. If you've followed the instructions above it is:
SSLCertificateKeyFile /etc/pki/tls/private/ca.key

>Quit and save the file and then restart Apache
service httpd restart

>to then sync your calendar on the iphone with your google calendar
on the iphone, go to Setting --> Mail,Contacts,Calendars --> Add Account --> Other --> Add CalDAV Account
server = google.com
username = username@gmail.com
password = somepassword

congratulation, you now have push email and push calendar.
... now the only thing missing is the ability to sync your google contacts :-(
 
Hey @Diode, does this method still work for receiving push notifications on iPhone? I would appreciate a reply as I have been trying to get something like this working for a while now! I was using nuevasync but that has stopped supporting calendars…
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.