Solved

PHP to send mail through google smtp

Posted on 2013-02-02
3
442 Views
Last Modified: 2013-02-06
Hi,

I'm trying to get a contact form mailing through some php code.  The code works when I point it at a different mail server but when I point it at the production domain smtp address is doesn't work.

No errors, just no mail received.

the domain is hosted with a 3rd party domain host.  The webserver has a series of MX record entries as shown in the attached image.  

Here are the PHP smtp setting I used, unsuccesfully.  Again, the code works because when I point it to a different mail server everything works fine.

<?php
//Server Address
$SmtpServer="ssl://mail.xyzwebsite.com";//smtp.gmail.com
$SmtpPort="465";
$SmtpUser="fake@xyzwebsite.com";
$SmtpPass="123pass456";

?>

After trying it with no ssl, port 25, 26, and 587 without success I tried the ssl preamble.  Still no success.  Address & login work and are actual functioning google mail accounts under a google apps account.  The google accounts stuff works on the google side.  When I send an email from a 3rd party address to the google account address it's received fine showing that the dns & mx records are routing properly.  

I just can't push mail through with these params.

Can someone tell me what they think may be necessary to establish a successful connection to the google mail server?

Thanks,
sample
0
Comment
Question by:tf2012
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 total points
ID: 38847005
PHPMailer has demo code that works with Gmail.  http://code.google.com/a/apache-extras.org/p/phpmailer/wiki/PHPMailer
0
 
LVL 9

Assisted Solution

by:rinfo
rinfo earned 250 total points
ID: 38848352
why you have mentioned both the server address for smtp server
$SmtpServer="ssl://mail.xyzwebsite.com";//smtp.gmail.com
As far as i know if the smtpuser and smtppass are valid gmail account it would work with just smtp.gmail.com and smtp port would be 587.
0
 
LVL 1

Author Closing Comment

by:tf2012
ID: 38861710
switched over to different mail server but thanks anyway!
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySQL Persistent Connections 10 35
What Programs Are Available to Help Map Forms for PDF Creation 11 34
How to use 2 ON statements in inner join 3 27
PHP Curl Problem 10 42
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question