Your Server

PHP, SMTP, Gmail?

I'm using a vista box with xampp as a development environment. I'd like to use gmail as the smtp server. What alterations should I make to the php.ini file to enable this? Many thanks. I read this and figured it would be the easiest route. http://www.iopus.com/guides/bestpopsmtp.htm

Public Comments

  1. Gmail is a web site. If you want to run an SMTP server, look for an SMTP server - something like http://www.softstack.com/freesmtp.html maybe. Why depend on an external server to forward your email? (I run Postfix on a Linux box to be able to send my mail the way I want it sent.)
  2. It is definitely possible to use GMail as SMTP server and I have this successfully implemented on a couple of web sites. However, it will not work out of the box with XAMPP or any other PHP deployment for that matter. Nothing you can put into php.ini will help. The problem is that Gmail uses secure SMTP over SSL and requires SMTP authentication. PHP built-in 'mail' function is not capable of working with either. You need to write your own function that will send e-mail via SSL-based SMTP, or take any existing SMTP library and modify it to work with SSL. For example, I took this code: http://www.phpclasses.org/browse/package/2065.html And modified it to work with SSL, so the piece that actually sends e-mail looks like this: $smtp_url = "ssl://smtp.gmail.com"; $smtp_port = 465; $socket = fsockopen($smtp_url, $smtp_port, $errno, $errstr, 5); ... ..... fputs($socket, "AUTH LOGIN\r\n"); ssl_server_parse($socket, "334"); fputs($socket, base64_encode($smtp_username) . "\r\n"); ssl_server_parse($socket, "334"); fputs($socket, base64_encode($smtp_password) . "\r\n"); .....
Powered by Yahoo! Answers