Configura la función wp_mail de WordPress para que use envíos por SMTP y no la función mail() local. Fork en español del gist de Chad Butler: https://gist.github.com/butlerblog/c5c5eae5ace5bdaefb5d | http://b.utler.co/Y3
<?php | |
/** | |
* Empieza por poner las siguientes constantes en tu archivo wp-config.php. | |
* | |
* Has de ponerlas antes de la línea que define la cosntante ABSPATH. | |
* | |
* Ten en cuenta que has de cambiar el valor de todas las constantes acorde a | |
* la configuración de correo electrónico que te facilite tu proveedor de correo. | |
*/ | |
define( 'SMTP_USER', 'user@example.com' ); // Username to use for SMTP authentication | |
define( 'SMTP_PASS', 'smtp password' ); // Password to use for SMTP authentication | |
define( 'SMTP_HOST', 'smtp.example.com' ); // The hostname of the mail server | |
define( 'SMTP_FROM', 'website@example.com' ); // SMTP From email address | |
define( 'SMTP_NAME', 'e.g Website Name' ); // SMTP From name | |
define( 'SMTP_PORT', '25' ); // SMTP port number - likely to be 25, 465 or 587 | |
define( 'SMTP_SECURE', 'tls' ); // Encryption system to use - ssl or tls | |
define( 'SMTP_AUTH', true ); // Use SMTP authentication (true|false) | |
define( 'SMTP_DEBUG', 0 ); // for debugging purposes only set to 1 or 2 |
/** | |
* Con lo anterior definido será necesario que crees un nuevo plugin en tu instalación. | |
* | |
* Copia este archivo al directorio wp-content/plugins y asegúraet de activarlo accediendo a | |
* "WordPress → Plugins". | |
* | |
* El código de este archivo se encargará de hacer que wp_mail se conecte por SMTP a tu | |
* servidor de correo. Esto mejora la fiabilidad de wp_mail y evita problemas derivados de dejar | |
* que sea tu propio servidor el que use la función mail() y envíe con un remitente arbitrario. | |
* | |
* Las constantes es recomendable definirals en el archivo wp-config, tal y como explicamos en la parte superior de este gist. | |
* | |
* Autor: Chad Butler | |
* Página del autor: http://butlerblog.com | |
* Traducido por: Héctor Luaces <hector@luaces-novo.es> | |
* | |
* Para más información e isntrucciones revisar la página del autor original: | |
* http://b.utler.co/Y3 | |
*/ | |
add_action( 'phpmailer_init', 'send_smtp_email' ); | |
function send_smtp_email( $phpmailer ) { | |
if ( ! is_object( $phpmailer ) ) { | |
$phpmailer = (object) $phpmailer; | |
} | |
$phpmailer->Mailer = 'smtp'; | |
$phpmailer->Host = SMTP_HOST; | |
$phpmailer->SMTPAuth = SMTP_AUTH; | |
$phpmailer->Port = SMTP_PORT; | |
$phpmailer->Username = SMTP_USER; | |
$phpmailer->Password = SMTP_PASS; | |
$phpmailer->SMTPSecure = SMTP_SECURE; | |
$phpmailer->From = SMTP_FROM; | |
$phpmailer->FromName = SMTP_NAME; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment