forum.coppermine-gallery.net
Support => cpg1.5.x Support => cpg1.5 email => Topic started by: rafiki on September 07, 2012, 05:10:21 pm
-
Good afternoon,
I'm hitting a dead end.
I've set up a new gallery on a new webhost. URL: http://petitadrien.fr/photos/
Everything works fine except the emails that are never sent out.
I did try the following test script placed in the root folder of my gallery, it worked fine and sent out the email with the correct sender.
<?php
// Mettez ici votre adresse valide
$to = "removed@nonemail.com";
// Sujet du message
$subject = "Test fonction mail() de PHP";
// Corps du message, écrit en texte et encodage iso-8859-1
$message = "Bonjour,\nl'envoi du mail via PHP a reussi. Le webmaster\n";
// Entêtes du message
$headers = ""; // on vide la variable
$headers = "From: Webmaster Site <removed@nonemail.com>\n"; // ajout du champ From
// $headers = $headers."MIME-Version: 1.0\n"; // ajout du champ de version MIME
$headers = $headers."Content-type: text/plain; charset=iso-8859-1\n"; // ajout du type d'encodage du corps
// Appel à la fonction mail
if ( mail($to, $subject, $message, $headers) == TRUE )
{
echo "Envoi du mail reussi.";
}
else
{
echo "Erreur : l'envoi du mail a echoue.";
}
?>
I left all email settings blank in my gallery configuration and tested several times with the e-cards.
Here's what I get in the debug output:
/include/mailer.inc.php•Warning line 588: mail() [function.mail]: Unable to retrieve servername infos
•CPG Notice line 1694: Could not instantiate mail function.
I searched the forum for the similar error but could not find a similar case.
Can you please provide assistance to solve that issue?
Thank you
-
I left all email settings blank in my gallery configuration
As a quick fix you could try to use an SMTP server, if that's possible. If not, please reply and we'll try to fix your issue.
-
I did try the SMTP settings with a gmail account.
It triggered another type of error.
I did not want to mix the 2 issues, but here's what I get with a gmail test in the debug output:
•Warning line 2113: fsockopen() [function.fsockopen]: SSL: Success
•Warning line 2113: fsockopen() [function.fsockopen]: Failed to enable crypto
•Warning line 2113: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unknown error)
•CPG Notice line 1694: SMTP Error: Could not connect to SMTP host.
Does this help?
-
Let's try to fix the non-SMTP version. In include/mailer.inc.php you'll find
function MailSend($header, $body) {
$to = '';
for($i = 0; $i < count($this->to); $i++) {
if($i != 0) { $to .= ', '; }
$to .= $this->AddrFormat($this->to[$i]);
}
$toArr = split(',', $to);
if ($this->Sender != '' && strtolower(ini_get('safe_mode')) != 'on' && ini_get('safe_mode') != 1) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
$params = sprintf("-oi -f %s", $this->Sender);
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
ini_set('sendmail_from', $old_from);
} else {
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
}
}
if(!$rt) {
$this->SetError($this->Lang('instantiate'));
return false;
}
return true;
}
which is used if no SMTP data is set. If I remember correctly we already had a similar issue, unfortunately I wasn't able to find that thread. However, I assume that some parameter breaks Coppermine's mail function (i.e. the mail server doesn't like them), but it should be possible to fix it.
First of all I'd try if it works if you remove $params at all occurrences and if that doesn't work additionally remove $header. Please report the result.
-
First of all I'd try if it works if you remove $params at all occurrences and if that doesn't work additionally remove $header. Please report the result.
Hello André,
I did try to remove the variables as you specified in the MailSend function to end up with this syntax
function MailSend($body) {
$to = '';
for($i = 0; $i < count($this->to); $i++) {
if($i != 0) { $to .= ', '; }
$to .= $this->AddrFormat($this->to[$i]);
}
$toArr = split(',', $to);
if ($this->Sender != '' && strtolower(ini_get('safe_mode')) != 'on' && ini_get('safe_mode') != 1) {
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
$params = sprintf("-oi -f %s", $this->Sender);
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body);
}
ini_set('sendmail_from', $old_from);
} else {
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body);
}
}
if(!$rt) {
$this->SetError($this->Lang('instantiate'));
return false;
}
return true;
}
I tried first removing only the $params and then the $header
In both cases I got the following output
/include/mailer.inc.php•Warning line 588: mail() [function.mail]: Unable to retrieve servername infos
•CPG Notice line 1694: Could not instantiate mail function.
Additional info if helpful on this host:
sendmail_path /usr/sbin/pxsendmail
safe mode is off
-
To be honest I'm not very experienced with such email troubleshooting. I just recognized that line:
Warning line 588: mail() [function.mail]: Unable to retrieve servername infos
Line 588 reads
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
Please change the parameters so they are equal to your test script:
// Mettez ici votre adresse valide
$to = "testemail@gmail.com";
// Sujet du message
$subject = "Test fonction mail() de PHP";
// Corps du message, écrit en texte et encodage iso-8859-1
$message = "Bonjour,\nl'envoi du mail via PHP a reussi. Le webmaster\n";
// Entêtes du message
$headers = ""; // on vide la variable
$headers = "From: Webmaster Site <photos@petitadrien.fr>\n"; // ajout du champ From
// $headers = $headers."MIME-Version: 1.0\n"; // ajout du champ de version MIME
$headers = $headers."Content-type: text/plain; charset=iso-8859-1\n"; // ajout du type d'encodage du corps
// Appel à la fonction mail
$rt = @mail($to, $subject, $message, $headers);
Please report if it works with that hard-coded parameters.
-
Thank you for the proposal.
I tried to hardcode, and replace line 588 by my script.
This leads to the following output:
/include/mailer.inc.php•Warning line 600: mail() [function.mail]: Unable to retrieve servername infos
•CPG Notice line 1706: Could not instantiate mail function.
Line 600 reads:
$rt = @mail($to, $subject, $message, $headers);
-
Try to replace the whole function with
function MailSend($header, $body) {
$to = '';
for($i = 0; $i < count($this->to); $i++) {
if($i != 0) { $to .= ', '; }
$to .= $this->AddrFormat($this->to[$i]);
}
$toArr = split(',', $to);
if ($this->Sender != '' && strtolower(ini_get('safe_mode')) != 'on' && ini_get('safe_mode') != 1) {
//$old_from = ini_get('sendmail_from');
//ini_set('sendmail_from', $this->Sender);
//$params = sprintf("-oi -f %s", $this->Sender);
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params);
}
//ini_set('sendmail_from', $old_from);
} else {
if ($this->SingleTo === true && count($toArr) > 1) {
foreach ($toArr as $key => $val) {
$rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
}
} else {
$rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header);
}
}
if(!$rt) {
$this->SetError($this->Lang('instantiate'));
return false;
}
return true;
}
-
Hello André
I did start from a fresh cpg 1.5.20 mailer.inc.php file.
I replaced the whole function with the proposed code.
Still no luck:
/include/mailer.inc.php
Notice line 588: Undefined variable: params
Warning line 588: mail() [function.mail]: Unable to retrieve servername infos
CPG Notice line 1694: Could not instantiate mail function.
-
I did try the following test script placed in the root folder of my gallery, it worked fine and sent out the email with the correct sender.
Did you actually receive the mail?
(and...by the way, if the mail addresses are real in your test script, they can be deleted on request)
I did try the SMTP settings with a gmail account.
Does gmail allow the use of it's servers for SMTP?
Can you retry with mail account(s) you have set up on your own server? (to lessen the possibility of getting caught in a spam filter...)
Have you asked your host for help? Some hosts place limitations on email to reduce spammers.
-
Did you actually receive the mail?
Yes I received it on a gmail account.
(and...by the way, if the mail addresses are real in your test script, they can be deleted on request)
Thank you for pointing it out, I have put the real email I have setup for the gallery, I will avoid next time.
Does gmail allow the use of it's servers for SMTP?
Can you retry with mail account(s) you have set up on your own server? (to lessen the possibility of getting caught in a spam filter...)
Have you asked your host for help? Some hosts place limitations on email to reduce spammers.
I don't know for Gmail, I tried to follow the coppermine's doc and it sounds like the simplest approach.
The host is not really helpful, I did ask them for guidance with their smtp settings and they sent me for the moment only copypaste type of answers pointing to their configuration guide.
That's why I was counting on using the standard function which works fine on a gallery I have a on free host, but I did not expect it to be different this time. I was too optimistic.
I will retry and insist with the host support in the mean time.
-
I removed your email address from the first post.
To be somewhat more complete in testing, I suggest:
- Run versioncheck.php on your site (note: not all errors are important)
- Try the mail function with Register or, even easier Contact
- phpinfo.php might reveal something (I can't be sure)
- Try the test script with mail account(s) you have set up on your own server
-
I still wonder where the following error message is generated and why I cannot find it with Google:
[function.mail]: Unable to retrieve servername infos
As far as I can see it isn't generated by Coppermine, at least such a string doesn't exist in any file.
-
Thank you all for your effort and suggestions.
I tried a couple of times but the webhost was not really helpful and blamed the CMS (Coppermine in this case) instead of trying to assist me.
I moved my gallery to a slower but free webhost and it worked like a charm.
This ticket can be closed.