WordPress SMTP settings

Hi Guys,

I am developing a plugin for wordpress and it is soon to be launched. While developing this plugin I wanted to test email functionality that is built in.

WordPress uses PHP’s mail function to send email

So to send message to external email address your local machine should be able accept your message for relay in other words localhost is by default seen as a mail server.

In other words WordPress doesn’t have any its own settings to configure a SMTP server. It assumes PHP’s mail function is working properly to send emails.

With Linux I guess either sendmail or postfix are used my many distros and are good enough to accept and send email to localhost user email address.

For *IX machine check where your php.ini file is and provide path to sendmail in following setting

But if you are running Windows box for you plugin development, then changing main PHP.INI file is what you are looking for.

So look for these settings

and make changes accordingly.

bottom line is that the SMTP server you will be using should accept anonymous emails and it should accept emails from your development host IP too.

I can cover more advanced setup for mail servers but that’s not this post is about.

Now you can also set wordpress to work with gmail etc. i.e. external Mail Servers

In wordpress 3.3.x Open /wp-includes/pluggable.php and you will find function called wp_mail

That’s the function that is used to send emails right! On line number 210 you will see this declaration

Just below that you will find that it gets initialized if its missing.

Now on line 394 you will find this declaration

Change above to this

 

You have 2 options here. Either to append these lines and after the above line

and make required settings OR to open /wp-includes/class-phpmailer.php

and set the values to required ones.

Now you may need to set some extra options like port or SMTPSecure if you want to use Gmail as SMTP that operates on non-standard port.

So I hope that you get the idea.

I’ll bring some more tips

Till then chiao!

Advertisement

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.