Skip to content

Instantly share code, notes, and snippets.

@RalfAlbert
Created September 27, 2012 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RalfAlbert/3794924 to your computer and use it in GitHub Desktop.
Save RalfAlbert/3794924 to your computer and use it in GitHub Desktop.
WordPress use SMTP instead of mail()
<?php
/**
* WordPress-Plugin use smtp instead of mail()
*
* PHP version 5.2
*
* @category PHP
* @package WordPress
* @subpackage UseSMTP
* @author Ralf Albert <me@neun12.de>
* @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt
* @version 1.0
* @link http://wordpress.com
*/
/**
* Plugin Name: UseSMTP
* Plugin URI: http://yoda.neun12.de
* Description: Using SMTP instead of mail()
* Version: 1.0
* Author: Ralf Albert
* Author URI: http://yoda.neun12.de
* License: GPLv3
*/
if( ! function_exists( 'usesmtp_init' ) ){
add_action( 'phpmailer_init', 'usesmtp_init' );
function usesmtp_init( $phpmailer ){
if( ! is_object( $phpmailer ) )
$phpmailer = (object) $phpmailer;
$phpmailer->Mailer = 'smtp'; // telling the class to use SMTP
// possible values are 'mail', 'sendmail' or 'smtp'
$phpmailer->Host = "mailserver-eintragen"; // set the SMTP server host
$phpmailer->Port = 465; // set the SMTP server port
$phpmailer->SMTPSecure = "ssl"; // enable SMTP via SSL
$phpmailer->SMTPAuth = true; // enable SMTP authentication
$phpmailer->Username = "benutzername"; // set the SMTP account username
$phpmailer->Password = "password"; // set the SMTP account password
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment