Mi servidor me dijo que la funcion mail() nativa de PHP estaba desactivada por razones de seguridad, con lo cual los mails de mi página y de este blog dejaron de llegar.
Para solucionarlo, buscando un poco, encontré:
Para las webs, una librería (clase) super completa y de poca configuración:
Si tenés una cuenta de gamail podés usar el servidor SMTP de gmail para enviar mails (hasta 200 por hora, limite de gmail)
Se configura así:
include("class.phpmailer.php");
include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded
$mail = new PHPMailer();
$body = file_get_contents('contents.html'); /* o bien escribe el body text */
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "yourname@gmail.com"; // GMAIL username
$mail->Password = "password"; // GMAIL password
$mail->From = "replyto@yourdomain.com";
$mail->FromName = "Webmaster";
$mail->Subject = "This is the subject";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddReplyTo("replyto@yourdomain.com","Webmaster");
$mail->AddAttachment("/path/to/file.zip"); // attachment (optativo)
$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment (optativo)
$mail->AddAddress("username@domain.com","First Last");
$mail->IsHTML(true); // send as HTML ESTO INDICA SI EL CUERPO DEBE SER INTERPRETADO COMO HTML o PLAIN TEXT
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
Como ves, permite adjuntar archivos y todo….
Por su parte para WordPress el plugin wp-mail-smtp.0.9.1
te permite hacer exactamente lo mismo pero dentro de WP.
Bajás el plugin, lo colocás en la carpeta /wp-content/plugins , lo activás, y lo configurás con tus datos de cuenta de gmail.
NOTA: el server de gmail es: smtp.gmail.com puerto 465 (SIEMPRE)
debe ir bajo protocolo seguro SSL (los email salen encriptados, mayor seguridad).
Sin comentarios a “alternativa a mail() de PHP | mail() is disable for security reasons”
Por favor espera
Deja una respuesta