Mail sending via SMTP for WordPress

I was looking for some really simple SMTP solution for WordPress, only some code to send emails via SMTP. Without a plugin for localhost usage.

Came up with the following script in wp-content/mu-plugins/smtp.php

<?php
add_action('phpmailer_init', 'custom_phpmailer_init');
function custom_phpmailer_init($phpmailer) {  
 $phpmailer->IsSMTP();
 $phpmailer->Host = 'smtp.example.com';
 $phpmailer->SMTPDebug = 0;
 $phpmailer->SMTPAuth = true;
 $phpmailer->SMTPSecure = "ssl";
 $phpmailer->Port = 465;
 $phpmailer->Username = 'info@example.com';
 $phpmailer->Password = '';

return $phpmailer;
}
Advertisements

About Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/
This entry was posted in Uncategorized, wordpress and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s