August, 2013

  • DaveDev

    How do I send Email with WordPress hosted on Azure Websites?

    • 0 Comments

     

    Via DaveDev.net

     

    Overview

    Recently I moved my old MSDN Blog to the new DaveDev.net url running hosted WordPress on Azure WebSites.  Setting up the new blog couldn’t have been more simple (hint – Click New – Compute – WebSites – Gallery – WordPress in the Azure Dashboard) and only took about five minutes.

    The stuff that actually took the longest was customizing WordPress itself (themes, plugins, etc) , pointing the new Azure Website to a cname (davedev.azurewebsites.net to davedev.net) and then making sure I was backing up the MySQL Database.  One of the areas that was not obvious to me however was how to send Emails.

    Usually, if you sign up for WordPress from an online hoster or WordPress.com you will have an SMTP server set up for you which enables the  wp_mail() function to automatically send Email on  your behalf.  This is not the case when you are running WordPress on Azure but the good news is there is a free solution via the Azure Marketplace. 

    The intent of this post is to walk you through the steps to get started with Email (it’s a free service too) on your WordPress Azure Website instance.

    Contact Form

    WordPress offers a crazy amount of customizations so the first step you need to do is to decide how you want to enable people to contact me on my Blog.  After sifting through a bunch of contact form plugins I decided on one that would allow me to add a new tab and a clean contact form.

    Here is what the Contact Tab looks like now on my Blog in a typical desktop browser:

    ContactTab

    Clicking on Contact will take the blog visitor to a clean contact form where they can enter their name, email I can each them at and then their message.

    ContactForm

    Once they click send they will get a response message if their Email has been sent correctly back to me.

    ContactSent

    If you have tried adding a similar contact plugin to your Azure Websites hosted WordPress instance this is where you will first encounter problems.  Any call to send wp_mail() will result in an error as the Azure instance doesn’t know what SMTP server to use.  I will cover that in a bit but first let’s walk through what the generated Email will look like.

     

    ContactEmailReceived

    You can easily apply filters now to the incoming Blog Emails and when you hit Reply to the Email it will be sent to the Email address the Blog visitor filled out in your Contact Form.

    Setting things up

    So how did I go about creating the Contact Form and enable Emails?  The first step was to install the plugin I wanted to use for Blog Feedback Emails.  I chose Contact Form 7 and then activated the Form as seen below.

    PluginContactForm7

    The Contact Form will add a new menu option in your WordPress Dashboard called Contact.  Opening it up will show a new form called “Contact form 1” with some code in it.

    ContactForm7

    I copied the code from the Contact Form 1 and pasted it into a new Page for my Blog called “Contact”.

    ContactFormCode

    This is the Contact page you now see listed in my Blog’s Tab Menu.  Now that I have a Contact Form Up and running the next step was to sign up for an SMTP Service that would send Emails on my behalf.

    Setting Up SendGrid as a SMTP Service

    In order for our Contact Page to send Emails we will need a SMTP Service.  Luckily for us SendGrid offers just that and is part of the Azure Store.

    sendgrid2

    Simply open up the Azure Dashboard, click New, select Store and then choose SendGrid from the App Services Add-ons list.

    sendgridnew

    There is a completely free tier that will enable you to get (or blast out) up to 25,000 emails a month.  That is more than enough for the purposes of a Feedback page on our Blog.

    sendgridnew2

    Like all products in the Azure Store billing is integrated with your Azure monthly Bill as is single sign on.  I get complete status for the Sendgrid Service right from my Azure Dashboard and clicking on the SendGrid Name will take me to the SendGrid portal using my Azure credentials.

    sendgrid

    The only additional step needed is to verify your email address (which will be your Microsoft ID assigned to your Azure account).  Once that is done be sure to copy over your SendGrid username and password right from the AppBar by clicking Connection Info.

    You will also receive an Email from the Azure Store confirming your purchase of the SendGrid service using the free tier.

    SendgridFree

     

    Setting Up WordPress to use a custom SMTP Service

    Now that we have a Contact Form set up, and the SendGrid SMTP Service enabled we need to update our WordPress Blog so that any calls to the wp_mail() function will be routed to our new SMTP Service.

    There are a bunch of free WordPress plugins that will allow you to do this I chose to go with WP-Mail-SMTP.

    MailSMTP

    This plugin will add a new Email option in the Settings menu for your WordPress Dashboard.  This is where you can set up your From and Name for the Email.  Make sure you select SMTP for Wordpress emails, and then enter your SendGird information as seen below.  Make sure you use the smtp.sendgrid.net SMTP Host name and specify a port.  I used 587 based on the SendGrid recommendations.

    EmailSettings

     

    Conclusion

    That’s it!  You can now send a Test message to yourself using the same settings page or go back to your Contact Form and send one from there.  The only remaining recommendation I would have is to turn off new comment notifications inside your WordPress Dashboard.  This is enabled by default but since my WordPress Azure Website instance could not send emails before I wasn’t getting spammed.  Once the SMTP Host was set up I started to get notified every time a spam comment came in and oh my there are a lot of those with WordPress. 

    -Dave

  • DaveDev

    How do I stop Spam with WordPress hosted on Azure Websites?

    • 0 Comments


    Via Davedev.net


    Overview

    In my recent post on how to Setup Email with WordPress hosted on Azure Websites I mentioned the spam problem that will occur when running WordPress.  As an example here is the amount of spam I have received since moving my MSDN Blog onto WordPress in Azure Websites two months ago.

    Spam 

    By default any new comments on your blog posts will not be visible until you have approved them.  In the past this meant each morning I would go through 10+ comments that all lead to a crazy spam email address outside the United States.  If you’ve been running into the same issue there is a quick an easy fix!

    Captcha

    Log into your Azure Websites hosted WordPress dashboard, select Plugins, and then Add new.  Do a Search for Captcha and you will get back a list of popular plugins like below.

    CaptchaResults

    After looking at the details and user Ratings I decided to go with Captcha.

    Captcha1

    Once the Plugin is installed open up your Dashboard and select the Installed Plugins Menu.  Verify that the Captcha Plugin has been activated.

    SpamBlock1

    You can modify the settings if you only want certain Arithmetic functions for example, but I kept the defaults as is.

    Captcha2

    Save your changes and you are all set!  The Captcha will appear on your Login forms, comments, and registrations. 

    CaptchaLogin

    Registered users will not be bothered by any Captcha (you can turn this off if you wish) thus making it seamless for your blog commenters and restrictive for Spammers.

    CaptchaComments

    Conclusion

    Since I installed the Captcha plugin a few days ago I have not received a single spam comment on my Blog.  I highly recommend installing a similar plugin if you are running WordPress hosted on Azure Websites.

    -Dave

  • DaveDev

    Looking to get started with Cloud Computing? Check out my new Up and Running with Azure courses!

    • 0 Comments


    Via Davedev.net

    Azure

    I am happy to announce that I have two new courses published today on Lynda.com!  These courses are designed to take you from the very basic concepts of Cloud Computing,  installing the tools and then all the way up to creating a fully functional Cloud Application.  Full source code is included along with chapter by chapter code snippets and Visual Studio solutions.  I hope you enjoy watching them as much as I did creating them.

    Up and Running with Azurelynda_dot_com-150x150

    Windows Azure is an open and flexible cloud platform that enables developers to quickly build, deploy, and manage applications across a global network of Microsoft-managed datacenters. If you have been wondering how you can take advantage of "the cloud" and integrate it into your existing IT environment, this course is for you. David Isbitski covers everything from the basics of signing up for a free Azure account to using the free developer tools, and covers each of the six major offerings from Azure: virtual machines; website development; Mobile Services for authenticating users and storing data; the Cloud Services API development and deployment tools; Data Services, which incorporates SQL, Table, and Blob storage; and app services like Service Bus for messaging. At the end, you'll tie it all together in a 5-node cloud service that processes operations through Web and Workers roles, communicates through a Service Bus message queue, and saves data to the cloud.

    Topics include:

    • What is cloud computing?
    • What is Windows Azure?
    • Creating a Windows Azure virtual machine
    • Creating and deploying an Azure website
    • Adding Worker and Web roles to your cloud service
    • Creating a new SQL database
    • Writing and reading from the Service Bus queue
    • Saving queue messages to Table storage

    Up and Running with Azure Mobile Serviceslynda_dot_com-150x150

    Windows Azure Mobile Services accelerate your mobile app development by offering easy-to-use, scalable backend services. Your websites and mobile apps can leverage its structured storage, user authentication, and push notifications in familiar programming languages. In this course, David Isbitski uses Azure Mobile Services to build a new service and connect it to an existing Windows Store game built in HTML and JavaScript. Learn to add gamer profiles with the identity service, pull down basic Facebook profile information for gamers, add high score tables to the database, and create an API that will allow anyone on the web to retrieve and display the current highest score. Dive in now and get started setting up your account, using the developer tools, and diagnosing and scaling your services across the web.

    Topics include:

    • Setting up Visual Studio, Node.js, and the Azure Mobile Services SDK
    • Creating a new Azure Mobile Service instance
    • Connecting an app to a new service
    • Creating and managing storage tables
    • Setting up Facebook authorization
    • Storing app data in the cloud
    • Sending out push notifications
    • Setting up an API service
    • Adding custom logging

    -Dave

Page 1 of 1 (3 items)