Sending all emails using SMTP

I tried using both Configure SMTP and WP Mail SMTP to send all domain emails through my donotreply Google Apps email address, but neither plugin worked. Attempting to send test emails through either results in the error SMTP -> ERROR: Failed to connect to server: Network is unreachable (101). I entered the information correctly (smtp.gmail.com, port 465 OR 587 [tried both], SSL [also tried TLS]), but it cannot connect.

Is there something I may need to configure with my host or on the Apps dashboard to make it work properly? I had it working with this Google Apps account on a different domain with my same host, but that WordPress installation has been deleted.

Related posts

Leave a Reply

4 comments

  1. You are trying with your Gmail mail server and it’s blocked from Gmail not form your host.

    Enable Gmail less secure apps into your Gmail account.

    If you want to allow access anyway, follow these steps:

    1) Go to the Less secure apps section of your Google Account.

    2) Turn on Allow less secure apps. If you don’t see this setting, your administrator might have turned off less secure app account access.

    and use this setting: Outgoing Mail (SMTP) Server: smtp.gmail.com.

    Use Authentication: Yes.

    Use Secure Connection: Yes (TLS or SSL depending on your mail client/website
    SMTP plugin)

    Username: your Gmail account (e.g. user@gmail.com)

    Password: your Gmail password.

    Port: 465 (SSL required) or 587 (TLS required)

  2. It sounds like something to do with your website hosting company. Again, how does your function look like?

    I usually use something like this:

    function mailer_config(PHPMailer $mailer){
        $mailer->IsSMTP();
        $mailer->Host = "smtp.yourdomainhere.com";
        $mailer->Port = 25;   // look, this depends on your mail settings
        $mailer->SMTPDebug = 0; 
        $mailer->CharSet  = "utf-8";
        $mailer->From = "no-reply@yourdomainhere.com";
        $mailer->FromName = "Your Name Here";
    }
    add_action( 'phpmailer_init', 'mailer_config', 10, 1);
    

    You can read up more on that approach here: https://core.trac.wordpress.org/browser/tags/3.5/wp-includes/class-phpmailer.php

    Simply drop the complete function in your functions.php file.