a traves de gmail
El codigo que estoy usando es este:
Código PHP:
Ver original
<? // primero hay que incluir la clase phpmailer para poder instanciar //un objeto de la misma require "includes/class.phpmailer.php"; //instanciamos un objeto de la clase phpmailer al que llamamos //por ejemplo mail $mail = new phpmailer(); $mail->IsSMTP(); //Definimos las propiedades y llamamos a los métodos correspondientes del objeto mail //Con PluginDir le indicamos a la clase phpmailer donde se //encuentra la clase smtp que como he comentado al principio de //este ejemplo va a estar en el subdirectorio includes $mail->PluginDir = "includes/"; //Con la propiedad Mailer le indicamos que vamos a usar un //servidor smtp // $mail->Mailer = "smtp"; //Asignamos a Host el nombre de nuestro servidor smtp $mail->Host = "smtp.gmail.com"; $mail->Port = 465; //Le indicamos que el servidor smtp requiere autenticación $mail->SMTPAuth = true; $mail->SMTPSecure = "ssl"; //Le decimos cual es nuestro nombre de usuario y password $mail->Password = "XXXXX"; //Indicamos cual es nuestra dirección de correo y el nombre que //queremos que vea el usuario que lee nuestro correo $mail->FromName = "XXX"; //el valor por defecto 10 de Timeout es un poco escaso dado que voy a usar //una cuenta gratuita, por tanto lo pongo a 30 $mail->Timeout=30; //Indicamos cual es la dirección de destino del correo //Asignamos asunto y cuerpo del mensaje //El cuerpo del mensaje lo ponemos en formato html, haciendo //que se vea en negrita $mail->Subject = "Prueba de phpmailer"; $mail->Body = "<b>Mensaje de prueba mandado con phpmailer en formato html</b>"; //Definimos AltBody por si el destinatario del correo no admite email con formato html $mail->AltBody = "Mensaje de prueba mandado con phpmailer en formato solo texto"; //se envia el mensaje, si no ha habido problemas //la variable $exito tendra el valor true $mail->IsHTML(true); $exito = $mail->Send(); //Si el mensaje no ha podido ser enviado se realizaran 4 intentos mas como mucho //para intentar enviar el mensaje, cada intento se hara 5 segundos despues //del anterior, para ello se usa la funcion sleep $intentos=1; while ((!$exito) && ($intentos < 5)) { //echo $mail->ErrorInfo; $exito = $mail->Send(); $intentos=$intentos+1; } if(!$exito) { echo "Problemas enviando correo electrónico a ".$valor; echo "<br/>".$mail->ErrorInfo; } else { echo "Mensaje enviado correctamente"; } ?>
en la carpeta includes tengo las ultimas versiones de class.phpmailer.php y class.smtp.php
y al intentar ponen en marcha me sale el siguiente :
Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?) in /home/a3434157/public_html/includes/class.smtp.php on line 122
adjunto el codigo de class.smtp
Código PHP:
Ver original
<?php /*~ class.smtp.php .---------------------------------------------------------------------------. | Software: PHPMailer - PHP email class | | Version: 2.1 | | Contact: via sourceforge.net support pages (also [url]www.codeworxtech.com[/url]) | | Info: [url]http://phpmailer.sourceforge.net[/url] | | Support: [url]http://sourceforge.net/projects/phpmailer/[/url] | | ------------------------------------------------------------------------- | | Author: Andy Prevost (project admininistrator) | | Author: Brent R. Matzelle (original founder) | | Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. | | Copyright (c) 2001-2003, Brent R. Matzelle | | ------------------------------------------------------------------------- | | License: Distributed under the Lesser General Public License (LGPL) | | [url]http://www.gnu.org/copyleft/lesser.html[/url] | | This program is distributed in the hope that it will be useful - WITHOUT | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | | FITNESS FOR A PARTICULAR PURPOSE. | | ------------------------------------------------------------------------- | | We offer a number of paid services ([url]www.codeworxtech.com):[/url] | | - Web Hosting on highly optimized fast and secure servers | | - Technology Consulting | | - Oursourcing (highly qualified programmers and graphic designers) | '---------------------------------------------------------------------------' /** * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP * commands except TURN which will always return a not implemented * error. SMTP also provides some utility methods for sending mail * to an SMTP server. * @package PHPMailer * @author Chris Ryan */ class SMTP { /** * SMTP server port * @var int */ public $SMTP_PORT = 25; /** * SMTP reply line ending * @var string */ public $CRLF = "\r\n"; /** * Sets whether debugging is turned on * @var bool */ public $do_debug; // the level of debug to perform /** * Sets VERP use on/off (default is off) * @var bool */ public $do_verp = false; /**#@+ * @access private */ private $smtp_conn; // the socket to the server private $error; // error if any on the last call private $helo_rply; // the reply the server sent to us for HELO /**#@-*/ /** * Initialize the class so that the data is in a known state. * @access public * @return void */ public function __construct() { $this->smtp_conn = 0; $this->error = null; $this->helo_rply = null; $this->do_debug = 0; } /************************************************************* * CONNECTION FUNCTIONS * ***********************************************************/ /** * Connect to the server specified on the port specified. * If the port is not specified use the default SMTP_PORT. * If tval is specified then a connection will try and be * established with the server for that number of seconds. * If tval is not specified the default is 30 seconds to * try on the connection. * * SMTP CODE SUCCESS: 220 * SMTP CODE FAILURE: 421 * @access public * @return bool */ public function Connect($host,$port=0,$tval=30) { /* set the error val to null so there is no confusion */ $this->error = null; /* make sure we are __not__ connected */ if($this->connected()) { /* ok we are connected! what should we do? * for now we will just give an error saying we * are already connected */ return false; } $port = $this->SMTP_PORT; } /* connect to the smtp server */ $port, // the port to use $errno, // error number if any $errstr, // error message if any $tval); // give up after ? secs <<<<<linea 122 /* verify we connected properly */ "errno" => $errno, "errstr" => $errstr); if($this->do_debug >= 1) { echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF; } return false; }
Si me pueden ayudar se los voy a agradecer mucho pues mis conociemientos son muy limitados y si ves algun error en la configuaracion hacemelo saber
Gracias por adelantado o si tenes algun script que quieras compartir para ayudarme tambien me seria util