Support > cpg1.5 email
Mail Function does not work with my gallery but test script does
rafiki:
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.
--- Code: ---<?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.";
}
?>
--- End code ---
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:
--- Quote ---/include/mailer.inc.php•Warning line 588: mail() [function.mail]: Unable to retrieve servername infos
•CPG Notice line 1694: Could not instantiate mail function.
--- End quote ---
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
Αndré:
--- Quote from: rafiki on September 07, 2012, 05:10:21 pm ---I left all email settings blank in my gallery configuration
--- End quote ---
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.
rafiki:
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:
--- Quote ---•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.
--- End quote ---
Does this help?
Αndré:
Let's try to fix the non-SMTP version. In include/mailer.inc.php you'll find
--- Code: --- 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;
}
--- End code ---
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.
rafiki:
--- Quote from: André on September 11, 2012, 09:23:58 am ---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.
--- End quote ---
Hello André,
I did try to remove the variables as you specified in the MailSend function to end up with this syntax
--- Code: ---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;
}
--- End code ---
I tried first removing only the $params and then the $header
In both cases I got the following output
--- Quote ---/include/mailer.inc.php•Warning line 588: mail() [function.mail]: Unable to retrieve servername infos
•CPG Notice line 1694: Could not instantiate mail function.
--- End quote ---
Additional info if helpful on this host:
sendmail_path /usr/sbin/pxsendmail
safe mode is off
Navigation
[0] Message Index
[#] Next page
Go to full version