Bueno pues después de tanta pelea, al final he conseguido solucionar el graviiiiiiiiiisimo problema que hay con el emailer y el smtp para poder enviar emails en hostings gratuitos.
Os digo lo que he hecho:
Lo primero de todo, sino usamos servidor smtp, el email se enviará por el smtp del host, lo cual, en la mayoría de los casos si el servidor está petado o , nos da el típico error ya archiconocido:
Failed sending email :: PHP ::
DEBUG MODE
Line : 234
File : emailer.PHP
El que no quiera que salga ese error para que no lo vean los usuarios, solamente tiene que editar el emailer.php y comentar las líneas de código:
Código: Seleccionar todo
if (!$result)
{
message_die(GENERAL_ERROR, 'Failed sending email :: ' . (($this->use_smtp) ? 'SMTP' : 'PHP') . ' :: ' . $result, '', __LINE__, __FILE__);
}
Pero claro si hacemos esto, solo es para que no salga el mensaje y para que visualmente los usuarios crean que se han registrado correctamente. Aunque cuando sale el mensaje, los usuarios quedan registrados también. Pero weno solamente por estetica. Con esto solucionamos que no aparezca el error, pero no solucionamos el envio de emails. Bueno pues nada sigue leyendo...
Entonces después de mucho probar y probar, en este foro dicen que si sale ese error que usemos el servidor smtp de yahoo poniendo en la configuración de email que usamos smtp, con los datos: smtp.correo.yahoo.es o smtp.mail.yahoo.com según de donde sea la cuenta, despues que pongamos solo el usuario de yahoo, sin @yahoo.es, etc, etc. Pues todo eso no vale para nada pq no funciona si el host gratuito que tengamos tiene capada la función mail() de php. Y yahoo nose antes pero ahora creo que requiere autenticación para enviar por smtp. Con lo cual no funciona.
En el foro de phpbb.com indicarón hace poco (si quereis verlo pinchad
aquí ), que una posible solución para este error, sería que abrieramos el smtp.php y cambiaramos el código:
Código: Seleccionar todo
if( !$socket = @fsockopen($board_config['smtp_host'], 25, $errno, $errstr, 20) )
por este otro:
Código: Seleccionar todo
if( !$socket = @fsockopen($board_config['smtp_host'], 425, $errno, $errstr, 20) )
y que luego pusieramos los datos siguientes:
Usar smtp: si
Servidor smtp: smtp.google.com
Usuario smtp:
nuestracuenta@gmail.com
Password: nuestropassword
Esta opción tampoco funciona, ya que seguimos sin autenticación.
Bueno pues seguí peleandome y encontré el MOD BetterSMTP que sirve para poder usar un smtp con autenticación (Lo podéis bajar de
http://www.bytewize.com/linux/BetterSMTP.zip ). Lo instalé y cual fué mi sorpresa que me daba el error:
Código: Seleccionar todo
Fatal error: Cannot redeclare _() in /includes/smtp_squirrelmail/smtp_squirrelmail.php on line 128
Bien pues lo que hice fue esto:
Primero comenté la función (o si kieres borrala en vez de comentarla) function _($str) del smtp_squirremail.php:
Código: Seleccionar todo
/* If you want to remove the line below, you're probably running php with gettext... :>
function _($str) { # emulate gettext syntax to avoid errors
message_die(GENERAL_ERROR,$str, "", __LINE__, __FILE__);
}
*/
Segundo, reemplace la funcion parseBodyStructure() siguiente del archivo Message.class.php:
Código: Seleccionar todo
function parseBodyStructure($read, &$i, $sub_msg = '') {
$arg_no = 0;
$arg_a = array();
if ($sub_msg) {
$message = $sub_msg;
} else {
$message = new Message();
}
$this = $message;
for ($cnt = strlen($read); $i < $cnt; ++$i) {
$char = strtoupper($read{$i});
switch ($char) {
case '(':
switch($arg_no) {
case 0:
if (!isset($msg)) {
$msg = new Message();
$hdr = new MessageHeader();
$hdr->type0 = 'text';
$hdr->type1 = 'plain';
$hdr->encoding = 'us-ascii';
} else {
$msg->header->type0 = 'multipart';
$msg->type0 = 'multipart';
while ($read{$i} == '(') {
$msg->addEntity($this->parseBodyStructure($read, $i, $msg));
}
}
break;
case 1:
/* multipart properties */
++$i;
$arg_a[] = $this->parseProperties($read, $i);
++$arg_no;
break;
case 2:
if (isset($msg->type0) && ($msg->type0 == 'multipart')) {
++$i;
$arg_a[] = $this->parseDisposition($read, $i);
} else { /* properties */
$arg_a[] = $this->parseProperties($read, $i);
}
++$arg_no;
break;
case 3:
if (isset($msg->type0) && ($msg->type0 == 'multipart')) {
++$i;
$arg_a[]= $this->parseLanguage($read, $i);
}
case 7:
if (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822')) {
$msg->header->type0 = $arg_a[0];
$msg->header->type1 = $arg_a[1];
$msg->type0 = $arg_a[0];
$msg->type1 = $arg_a[1];
$rfc822_hdr = new Rfc822Header();
$msg->rfc822_header = $this->parseEnvelope($read, $i, $rfc822_hdr);
while (($i < $cnt) && ($read{$i} != '(')) {
++$i;
}
$msg->addEntity($this->parseBodyStructure($read, $i,$msg));
}
break;
case 8:
++$i;
$arg_a[] = $this->parseDisposition($read, $i);
++$arg_no;
break;
case 9:
++$i;
if (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822'))) {
$arg_a[] = $this->parseDisposition($read, $i);
} else {
$arg_a[] = $this->parseLanguage($read, $i);
}
++$arg_no;
break;
case 10:
if (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822'))) {
++$i;
$arg_a[] = $this->parseLanguage($read, $i);
} else {
$i = $this->parseParenthesis($read, $i);
$arg_a[] = ''; /* not yet described in rfc2060 */
}
++$arg_no;
break;
default:
/* unknown argument, skip this part */
$i = $this->parseParenthesis($read, $i);
$arg_a[] = '';
++$arg_no;
break;
} /* switch */
break;
case '"':
/* inside an entity -> start processing */
$arg_s = $this->parseQuote($read, $i);
++$arg_no;
if ($arg_no < 3) {
$arg_s = strtolower($arg_s); /* type0 and type1 */
}
$arg_a[] = $arg_s;
break;
case 'n':
case 'N':
/* probably NIL argument */
if (strtoupper(substr($read, $i, 4)) == 'NIL ') {
$arg_a[] = '';
++$arg_no;
$i += 2;
}
break;
case '{':
/* process the literal value */
$arg_s = $this->parseLiteral($read, $i);
++$arg_no;
break;
case '0':
case is_numeric($read{$i}):
/* process integers */
if ($read{$i} == ' ') { break; }
++$arg_no;
if (preg_match('/^([0-9]+).*/',substr($read,$i), $regs)) {
$i += strlen($regs[1])-1;
$arg_a[] = $regs[1];
} else {
$arg_a[] = 0;
}
break;
case ')':
$multipart = (isset($msg->type0) && ($msg->type0 == 'multipart'));
if (!$multipart) {
$shifted_args = (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822')));
$hdr->type0 = $arg_a[0];
$hdr->type1 = $arg_a[1];
$msg->type0 = $arg_a[0];
$msg->type1 = $arg_a[1];
$arr = $arg_a[2];
if (is_array($arr)) {
$hdr->parameters = $arg_a[2];
}
$hdr->id = str_replace('<', '', str_replace('>', '', $arg_a[3]));
$hdr->description = $arg_a[4];
$hdr->encoding = strtolower($arg_a[5]);
$hdr->entity_id = $msg->entity_id;
$hdr->size = $arg_a[6];
if ($shifted_args) {
$hdr->lines = $arg_a[7];
$s = 1;
} else {
$s = 0;
}
$hdr->md5 = (isset($arg_a[7+$s]) ? $arg_a[7+$s] : $hdr->md5);
$hdr->disposition = (isset($arg_a[8+$s]) ? $arg_a[8+$s] : $hdr->disposition);
$hdr->language = (isset($arg_a[9+$s]) ? $arg_a[9+$s] : $hdr->language);
$msg->header = $hdr;
} else {
$hdr->type0 = 'multipart';
$hdr->type1 = $arg_a[0];
$msg->type0 = 'multipart';
$msg->type1 = $arg_a[0];
$hdr->parameters = (isset($arg_a[1]) ? $arg_a[1] : $hdr->parameters);
$hdr->disposition = (isset($arg_a[2]) ? $arg_a[2] : $hdr->disposition);
$hdr->language = (isset($arg_a[3]) ? $arg_a[3] : $hdr->language);
$msg->header = $hdr;
}
return $msg;
default: break;
} /* switch */
} /* for */
} /* parsestructure */
por esta otra:
Código: Seleccionar todo
function parseBodyStructure($read, &$i, $sub_msg = '') {
$arg_no = 0;
$arg_a = array();
if ($sub_msg) {
$message = $sub_msg;
} else {
$message = new Message();
}
for ($cnt = strlen($read); $i < $cnt; ++$i) {
$char = strtoupper($read{$i});
switch ($char) {
case '(':
switch($arg_no) {
case 0:
if (!isset($msg)) {
$msg = new Message();
$hdr = new MessageHeader();
$hdr->type0 = 'text';
$hdr->type1 = 'plain';
$hdr->encoding = 'us-ascii';
} else {
$msg->header->type0 = 'multipart';
$msg->type0 = 'multipart';
while ($read{$i} == '(') {
$msg->addEntity($msg->parseBodyStructure($read, $i, $msg));
}
}
break;
case 1:
/* multipart properties */
++$i;
$arg_a[] = $msg->parseProperties($read, $i);
++$arg_no;
break;
case 2:
if (isset($msg->type0) && ($msg->type0 == 'multipart')) {
++$i;
$arg_a[] = $msg->parseDisposition($read, $i);
} else { /* properties */
$arg_a[] = $msg->parseProperties($read, $i);
}
++$arg_no;
break;
case 3:
if (isset($msg->type0) && ($msg->type0 == 'multipart')) {
++$i;
$arg_a[]= $msg->parseLanguage($read, $i);
}
case 7:
if (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822')) {
$msg->header->type0 = $arg_a[0];
$msg->header->type1 = $arg_a[1];
$msg->type0 = $arg_a[0];
$msg->type1 = $arg_a[1];
$rfc822_hdr = new Rfc822Header();
$msg->rfc822_header = $msg->parseEnvelope($read, $i, $rfc822_hdr);
while (($i < $cnt) && ($read{$i} != '(')) {
++$i;
}
$msg->addEntity($msg->parseBodyStructure($read, $i,$msg));
}
break;
case 8:
++$i;
$arg_a[] = $msg->parseDisposition($read, $i);
++$arg_no;
break;
case 9:
++$i;
if (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822'))) {
$arg_a[] = $msg->parseDisposition($read, $i);
} else {
$arg_a[] = $msg->parseLanguage($read, $i);
}
++$arg_no;
break;
case 10:
if (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822'))) {
++$i;
$arg_a[] = $msg->parseLanguage($read, $i);
} else {
$i = $msg->parseParenthesis($read, $i);
$arg_a[] = ''; /* not yet described in rfc2060 */
}
++$arg_no;
break;
default:
/* unknown argument, skip this part */
$i = $msg->parseParenthesis($read, $i);
$arg_a[] = '';
++$arg_no;
break;
} /* switch */
break;
case '"':
/* inside an entity -> start processing */
$arg_s = $msg->parseQuote($read, $i);
++$arg_no;
if ($arg_no < 3) {
$arg_s = strtolower($arg_s); /* type0 and type1 */
}
$arg_a[] = $arg_s;
break;
case 'n':
case 'N':
/* probably NIL argument */
$tmpnil = strtoupper(substr($read, $i, 4));
if ($tmpnil == 'NIL ' || $tmpnil == 'NIL)') {
$arg_a[] = '';
++$arg_no;
$i += 2;
}
break;
case '{':
/* process the literal value */
$arg_a[] = $msg->parseLiteral($read, $i);
++$arg_no;
break;
case '0':
case is_numeric($read{$i}):
/* process integers */
if ($read{$i} == ' ') { break; }
++$arg_no;
if (preg_match('/^([0-9]+).*/',substr($read,$i), $regs)) {
$i += strlen($regs[1])-1;
$arg_a[] = $regs[1];
} else {
$arg_a[] = 0;
}
break;
case ')':
$multipart = (isset($msg->type0) && ($msg->type0 == 'multipart'));
if (!$multipart) {
$shifted_args = (($arg_a[0] == 'text') || (($arg_a[0] == 'message') && ($arg_a[1] == 'rfc822')));
$hdr->type0 = $arg_a[0];
$hdr->type1 = $arg_a[1];
$msg->type0 = $arg_a[0];
$msg->type1 = $arg_a[1];
$arr = $arg_a[2];
if (is_array($arr)) {
$hdr->parameters = $arg_a[2];
}
$hdr->id = str_replace('<', '', str_replace('>', '', $arg_a[3]));
$hdr->description = $arg_a[4];
$hdr->encoding = strtolower($arg_a[5]);
$hdr->entity_id = $msg->entity_id;
$hdr->size = $arg_a[6];
if ($shifted_args) {
$hdr->lines = $arg_a[7];
$s = 1;
} else {
$s = 0;
}
$hdr->md5 = (isset($arg_a[7+$s]) ? $arg_a[7+$s] : $hdr->md5);
$hdr->disposition = (isset($arg_a[8+$s]) ? $arg_a[8+$s] : $hdr->disposition);
$hdr->language = (isset($arg_a[9+$s]) ? $arg_a[9+$s] : $hdr->language);
$msg->header = $hdr;
} else {
$hdr->type0 = 'multipart';
$hdr->type1 = $arg_a[0];
$msg->type0 = 'multipart';
$msg->type1 = $arg_a[0];
$hdr->parameters = (isset($arg_a[1]) ? $arg_a[1] : $hdr->parameters);
$hdr->disposition = (isset($arg_a[2]) ? $arg_a[2] : $hdr->disposition);
$hdr->language = (isset($arg_a[3]) ? $arg_a[3] : $hdr->language);
$msg->header = $hdr;
}
return $msg;
default: break;
} /* switch */
} /* for */
} /* parsestructure */
Y YA POR ÚLTIMO LO QUE HICE FUE ESTO:
En el panel de control de configuración del foro, puse esto:
Usar servidor SMTP para el correo: ---------------------> SI
Dirección del Servidor SMTP: ----------------------------> smtp.gmail.com
Puerto SMTP: ----------------------------------------------> 465
Usuario SMTP ---------------------------------------------->
mi_usuario@gmail.com
Clave SMTP: -----------------------------------------------> mi clave
Método de Autenticación ----------------------------------> login
El servidor usa Autenticación Segura (SSL/TLS): ------> SI
(acordaros que en Usuario SMTP va con la @gmail.com todo enterito. De todas formas eso lo vereis en las ayudas de cada servidor smtp para configurar el POP/SMTP y acceder desde otros programas.)
Para los que useis otro servidor, teneis que mirar que Método de Autenticación usa. Lo podeis hacer haciendo en un terminal msdos:
telnet smtp.servidorsmtpquetenga.com 25
Despues poneis:
EHLO test.com
y donde os ponga 250-AUTH sería el metodo usado por ese server.
PD: SI EL HOSTING GRATUITO QUE USAIS, NO TIENE INSTALADO EN SU PHP EL MODULO DE OPENSSL, NO VAIS A PODER USAR EL MOD BETTERsmtp. Si quereis saber si lo tiene instalado solamente teneis que hacer una llamada a la función phpinfo() en vuestro host
Pues eso es todo. Espero haberos ayudado en algo ya que yo durante estos días me he dejado la vista buscando por muchos sitios una posible solución. Espero que a vosotros no os pase.
Un saludo