Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

e-mails not sent

Status
Not open for further replies.

breaststroke

Programmer
Apr 10, 2011
39
0
0
ES
Hello, I would really appreciate if I get some help on the following problem:

I have a script for sending emails through phpmailer.
I have tried changing several things, such us username and password of my mail server, limit at the SQL query, etc. After those changes I usually manage to send some emails, but always after a couple days the script stop working.
I am not being able to figure out where the problem lies, since it seems that doing the same changes it is not enought to make it work.
This is my script:

Code:
..
include('conexioninclude.php');
mysql_set_charset('utf8');
$registros=mysql_query("SELECT password,mail,name,code,time FROM table WHERE registration= '0' 
AND review !='no' limit 2",$conexion)or 
 die("Problems with select:".mysql_error());  
while($reg=mysql_fetch_array($registros)) 
{ 
$code=$reg['code'];
$namename=$reg['name'];
$mailmail=$reg['mail'];
$password=$reg['password'];
$time=$reg['time'];
$timerightnow=time();
$dif=($timerightnow-$time);
if($dif>80000)
{
require_once("class.phpmailer.php");
$mail = new PHPMailer(); 
$mail->IsSMTP();
$mail->Port = xxxxxxx;
$mail->SMTPSecure = "ssl";                 
$mail->Host  = "smtp.gmail.com";     
$mail->SMTPAuth = true; 
$mail->Username = "xxxxxxx"; 
$mail->Password = "xxxxxxxx"; // SMTP password
$webmaster_email = "xxxxxxx"; //Reply to this email ID
$email="xxxxxxxxx"; // Recipients email ID
$name="Admin"; // Recipient's name
$mail->From = "xxxxxxxx";
$mail->FromName = "xxxxxxxx";
$mail->AddAddress($mailmail,$namename);
$mail->AddReplyTo($webmaster,"Webmaster");
$mail->WordWrap = 50; // set 
$mail->IsHTML(true); // send as HTML
$mail->Subject = "test";
$foto= "public_html/foto.jpg";
$mensaje='<img src="'.$foto.'" \><br /><br />
xxxxxxxxx';
 

$mail->MsgHTML($mensaje);


if(!$mail->Send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "fine";
}
}
}
..

The error I am getting now is the following:
"Mailer Error: Language string failed to load: connect_host"
,although I would swear I got different errors in previous occasions.
Thank you very much in advance!!
My regards


enjoy practicing languages at:
 
ensure you are using the very latest version of phpmailer. and in preference use the default (english) language or at least ensure that all the language pack files are available to phpmailer.

fixing this will just give you the _correct_ error message. You are not properly connecting to the gmail server. one of the port, username or password are incorrect.

set the port to 465.

 
jpadie, thank you.

This is the php version I am working with: 5.2.15.
I have checked it and my port is actually set to 465, as you suggest. Sorry for not having added it before.
This is my phpmailer version: 2.0.0 rc3.
Would you recommend I switch to another?

I added the following to the email sending script:
$mail->SetLanguage("en","/php/language/");
but I keep receiving the same message.
I have also found this at class.phpmailer file:

"* Sets the language for all class error messages. Returns false
* if it cannot load the language file. The default language type
* is English."

So it looks like it is set as you suggest jpadie.
I have tried adding new Password and Username from recently opened gmail accounts. It is not working now, and I don't really know whether it has in the past (because I was making a lot of changes and in the end I am not sure which one was working).

Thank you again!



enjoy practicing languages at:
 
I would include the absolute uri to the languages folder. It would be unusual for the Lang files to be stored just off the root like that (remember pretending a slash means root).

Also upgrade phpmailer to current. We are at 5.1 at present. Download the files from sourceforge.
 
Hi,

I have updated phpmailer to 5.1 version, and uploaded class.phpmailer.php , class.smtp.php and phpmailer.lang files to my server and I get the following error:
"Invalid address: SMTP Error: Could not authenticate. Mailer Error: SMTP Error: Could not authenticate"

I guess I have to configure something into any of those files but I don't remember what.

I would appreciate any help.
Thank you

enjoy practicing languages at:
 
opps, I am desperate.
I have turned back to my previous version, not to get stuck sending messages, since the previous version was working fine on other scripts (at least I tested it and it seemed to work), and now it is not even working on those scripts (the part related to phpmailer are the same as the one I have pasted here, only changed the query, and it was within an "if" conditional, not within a "while").Maybe it wasn't working always fine, but at least it did whenever I tried, but not now.

I wouldn't mind switching to the newest version, as I have already tried, but how can I solve those problems?.

Thanks.

enjoy practicing languages at:
 
you need to post the full code you are using.
you need to make sure that you are using the latest version of phpmailer.
this will assist us with debugging your code as we will receive a meaningful message from the mailer smtp subclass.
ensure, of course, that your gmail account is not locked out by attempting to log on manually through a web browser.
 
Hi,

you were pretty right recommending me have to check my email account, from the beginning.
I had already changed it just before posting about this issue.
That's why I was sure it was okeay, sorry.
I have checked it now, the new one, and it was actually locked out.
I have fixed it. But it looks like I am always having this issue (related to my gmail accounts).
I used to think it had to be something related to my script or to phpmailer but I see it isn't.
In fact, I guess once this script works there is no reason for it not to keep doing so. At least in my case seems to be always related to gmail.
I wonder if it may have to do with my hosting or the server my website is on, in a way that gmail tends not to accept emails sent by it. Or maybe it is just that I have had to open quite a few gmail accounts (becuase I did a lot of email-sending tests some months ago, and I think gmail ended up considering those accounts or emails as spam)and now gmail "distrust" my new accounts.
Whatever the reason is I feel more reassured, and I will check my email accounts If I encounter the same issue in the future.

As to the new phpmailer version (PHPMailer v5.1), I checked it too, even opening it files, and they say it is phpmailer version 5.1.
I have tried uploading its files agian, after having "fixed" my email issue and it keeps giving me the same error.
I downloaded the files from sourceforge, as you said. I don't really know what is happening.

Thank you again

enjoy practicing languages at:
 
if the account is getting locked out it is because the username/pwd combo is not correct 3 times in succession. you then have to go through the unlock process (with a captcha from memory).

all i can suggest is that you check, check again and then check again the username and pwd combo. I attach to google from one of my servers (although this is for imap rather than smtp) and have had no problems. i have (just) tested an smtp connection and that also works fine.

I'd suggest that it could be a firewall config issue at your server but this is very improbable given that your account got locked out. It all points to the uname/pwd combo in your script being wrong.
 
hi,

I am not sure if I understand what you mean.
I opened a new account. I changed the username and password and I didn't touch or change it again. How come it worked the first try and not the following ones without having changed them?. If they were wrong and gmail account got locked at the third try, it shouldn't have worked the first time either.
It is the way I see it. Maybe I am wrong.

Thank you


enjoy practicing languages at:
 
if it has worked once, and there has been no intervening change to the web server on which your code resides (and where your internet gateway is), there can be nothing wrong with your code.

if you are really and truly 100% certain of your facts then the issue must be with the gmail server or another client. the former is very unlikely. Occam's razor suggests that the issue thus lies with another client that you have set up that polls your gmail account. If the client is being polled two frequently then it will lock out. If there is too much data transfer, it will lock out for 24 hours. If your other client is incorrectly configured and is getting the uname/pwd combo wrong, then the account will lock out.

consider, perhaps, a different smtp server (perhaps localhost based) unless there is a pressing need to use google.
 
Thank you,

You are giving me a lot of information around this issue that is and may be useful for me in the future.
Although , due to my limited knowledge, I don't know what client set up by me may be polling my gmail account. Could I check its configuration?

In any case, thank you very much. I will take into account your advise.

enjoy practicing languages at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top