Question

PHP MAIL with Gmail.com

Asked by: okayguy911

I got an error even using cable
Fatal error: Maximum execution time of 60 seconds exceeded in S:\interpub\Mailing\class.smtp.php on line 1024
I'm using gmail to test
My gmail  Status: POP is enabled.
I included  the username and password in my script for test.
Seem like the gmail require to use ssl for outgoing and incoming.
I' m using phpmailer-1.73.
I changed  the Port on line 30  to port 465 file class.smtp.php
and line 162 to port 465 for the class.phpmailer.php


<?php
require('class.phpmailer.php');

//gmail setup
//http://mail.google.com/support/bin/answer.py?answer=13276&query=pop&topic=&type=f&ctx=search
//Enter '465' in the 'Outgoing mail (SMTP):' field.
///pop.gmail.com
$mail = new PHPMailer();

$mail->IsSMTP();                                   // send via SMTP
$mail->Host     = "pop.gmail.com"; // SMTP servers
//$mail->Host     = "smtpout.secureserver.net;smtpout.secureserver.net"; // SMTP servers
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->Username = "xxxxxxx@gmail.com";  // SMTP username
$mail->Password = "PleaseDon'tChangeThisPassword"; // SMTP password

$mail->From = 'xxxxxxx@gmail.com';
$mail->FromName = 'from name';
$mail->AddAddress('xxxxxxx@gmail.com');


$mail->Subject  =  "Here is the subject";
$mail->Body     =  "This is the <b>HTML body</b>";
$mail->AltBody  =  "This is the text-only body";

if(!$mail->Send())
{
   echo "Message was not sent <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>

I read a little on
http://phpmailer.sourceforge.net/tutorial.html but nothing good.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2006-08-22 at 10:05:35ID21963190
Tags

gmail

,

php

,

mail

Topic

PHP for Windows

Participating Experts
1
Points
450
Comments
16

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. I want a php mailer or perl mailer.
    Hello, Can someone help me to build a php mailer or perl mailer to send mail with any hosting smtp server ? I wait for reply.
  2. PHP and Gmail!
    After hours of searching i cannot find an understandable way for me to use PHP's mail() function with my Gmail account! I set SMTP = smtp.gmail.com in my php.ini. Here is my code..
  3. how do I use gmail SMTP in PHP
    I am trying to use Gmail to send emails from my php web pages. I have downloaded PHPmailer. But when I try to send an email it says "Mailer Error: Language string failed to load: connect_host" Dont know whats wrong. Check my code and settings below. I am using IIS ...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: cristi_2112Posted on 2006-08-23 at 00:53:40ID: 17370225

Hello,

Read this - http://deepakssn.blogspot.com/2006/06/gmail-php-send-email-using-php-with.html
It is exactly what you need.

Good luck :)

 

by: cristi_2112Posted on 2006-08-23 at 00:55:13ID: 17370238

.. If you enable - extension=php_openssl.dll , and do how it's described in the article from the previous post, let us know so we can help you further

 

by: okayguy911Posted on 2006-08-23 at 08:04:00ID: 17373206

For now I can control my server, but later I'll put my script on godaddy.com which mean I have no controll on their server.


For now I just enable the php extension a did a little modified as on the Tech Meal said but seem like we have a fatal problem here

Warning: fgets() [function.fgets]: SSL: fatal protocol error in S:\interpub\class.smtp.php on line 1027
Message has been sent.
I did paste the code above the  #connect to the smtp server  and modified user name and password as they said.


$host = "ssl://smtp.gmail.com";
$port = 465;

 

by: okayguy911Posted on 2006-08-23 at 08:08:54ID: 17373240


I just recieved an email after my test script, but I still get the  Warning: fgets() [function.fgets]: SSL: fatal protocol error in S:\interpub\class.smtp.php on line 1027

 

by: okayguy911Posted on 2006-08-23 at 08:12:51ID: 17373276

Now I am trying to use the different email script with
http://pear.php.net/package/Mail

 

by: cristi_2112Posted on 2006-08-23 at 08:26:19ID: 17373403

but you said you received the mail sent with that script. So the only "problem" is that it gives the warning about fgets(), but it seems weird.
Anyway, evan if you use another class, you will still need to make a ssl connection, so you should find out if the company which will host your application has the ssl extension enabled in php.

 

by: okayguy911Posted on 2006-08-23 at 09:39:30ID: 17373998

seem like godaddy.com does not require ssl connection.
So all I need is a script which allow me to login then send email.

Man this take so much time to solve this problem

 

by: cristi_2112Posted on 2006-08-23 at 11:09:36ID: 17374836

but i'm wondering - doesn't godaddy.com have a smtp mail server you can use ?! I think it must have one.
Why don't you use their server ?!

 

by: okayguy911Posted on 2006-08-23 at 11:57:35ID: 17375239

I'm using gmail to test the outgoing, later I'll use the godaddy.com email to send email.
I knew that gmail they don't allow to use for commercial purpose.
This is just for test, I just got unlucky to ran into the ssl connection.

Let me use the godaddy.com email to test this baby here.

 

by: cristi_2112Posted on 2006-08-23 at 11:59:17ID: 17375253

at godaddy you should be able to send the email without any authentication needed.. you can use simple mail() call from php or the phpmailer, or any other opensource mail class :)

 

by: okayguy911Posted on 2006-08-23 at 12:37:30ID: 17375521

Are you sure, because I use the script below to test the but failed.
the xxxxxxx is my username and my domain.
I just send them an email about this problem.
I hope they will respond to me.


<?php
$from = "Sandra Sender <xxxxxxx@xxxxxxx.COM>";
$to = "xxxxxxx@xxxxxxx.COM>";

$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>

 

by: okayguy911Posted on 2006-08-23 at 12:38:31ID: 17375532

<?php
$from = "Sandra Sender <xxxxx@xxxxx.COM>";
$to = "Ramona Recipient <xxxxx@xxxxx.COM>";

$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>

 

by: okayguy911Posted on 2006-08-23 at 12:40:06ID: 17375546

damage my keyboard. I tried to hide my user name but.........
I'll send and email to experts-exchange to change my post

 

by: okayguy911Posted on 2006-08-23 at 12:44:35ID: 17375585

do any body how to email to experts-exchange to change my post, i don't want spammer to sent me like thousand email per day.

 

by: okayguy911Posted on 2006-08-23 at 12:45:36ID: 17375594

I mean do any body know how to contact  experts-exchange to change my post, I don't want spammer to send me like thousand email per day.

 

by: okayguy911Posted on 2006-08-24 at 09:01:43ID: 17382763

Man, goddady.com server is running safe mode.
I had a package with free hosting that's why.

That's I can't send any email out.

I just changed to the linux operation system on my account "still free"
and it works fine now.

I don't need to do any validation at all.
I'm so happy now!!!
The simple script below is doing fine already.
Yahoo!!!!!!!!!!!!!!!!!!!!!!


<?php
$from = "Sandra Sender <testme@xxxxxx.COM>";
$to = "Ramona Recipient <testme@xxxx.COM>";

$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
 } else {
  echo("<p>Message delivery failed...</p>");
 }
?>


I hope that the moderator will change my post.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...