• Has anyone gotten a smtp plugin to work with gmail? I have tried 4 plugins and they all time out trying to connect to gmail.

    I have exim disabled and all mail ports are closed on my server for security reasons.

    Any ideas?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Not a plugin. I have got gmail working but I’ve gone native to do it.

    I replaced the PHPMailer files (wp-includes/class-[phpmailer|smtp|pop].php) with the newer 2.2.1 files that support SSL/TLS connections.

    Edited the PHPMailer paramters in wp-include/class.phpmailer.php

    public $Host        = 'smtp.gmail.com';
    public $Port        = 465;
    public $SMTPSecure = "ssl";
    public $SMTPAuth     = true;
    public $Username     = '[username]';
    public $Password     = '[password]';

    Edited wp-include/pluggable.php

    require_once ABSPATH . WPINC . '/class.phpmailer.php';
    require_once ABSPATH . WPINC . '/class.smtp.php';

    [the original files used hyphens e.g. ‘/class-phpmailer.php’

    $phpmailer->IsSMTP(); // Use to be $phpmailer->IsMail();

    Hope this helps.
    -A.

    they all time out trying to connect to gmail…
    …Any ideas?

    Are you on a self hosted (or have full control on a VM) Linux box, and do you have SELinux features turned on?

    Has anyone gotten a smtp plugin to work with gmail?

    Well, on the off chance that others may benefit somehow from this information in the future, or that someone will contribute to my own knowledge if I am off-base, the answers is yes. In the case of time out errors; This can sometimes occur if you have a Linux server that uses SELinux security features. The default policy is usually to deny scripts any access to the network via httpd. You can allow the script (in this case the smtp plugins commonly used for gmail access), to connect by doing the following:

    If you have access to the the SELinux Administration interface (policycoreutils-gui), open it. Select “Boolean”, select “HTTPD Service”, and check the box for “Allow HTTPD scripts and modules to connect to the network”. That should be enough to allow the plugin to function.

    If you have command line only, you can usually view the available booleans with;

    getsebool -a (or if you like, grep just the httpd)

    Then this command will set the httpd connect permissions to on:

    setsebool -P httpd_can_network_connect on

    I recommend you read and understand about doing this, and be able to reverse the procedure should it not work for you, or you decide you don’t want it enabled. I also know that this is not the only reason for those plugins to fail. The only reason I offer it, is because of the notation of timeout errors, and the reference to disabling the Exim MTA, indicating the likely presence of a Linux server.

    I would be very interested to know if achampion’s method would work with the SELinux policy defaults in place. Intriguing stuff.

    achampion,
    I used your advice from above. This are working well. Thanks!

    One thing I might add though. My emails were coming from “WordPress”. I had to edit a line in pluggable.php. Just search for the line with $from_name and change “WordPress” to whatever you want to the From Name to be on emails from your WordPress installation.

    I found that https://www.ads-software.com/extend/plugins/swift-smtp/ worked on my 2.6.x installation. I had to enable the php openssl and also did sockets at the same time but the settings are fairly straightforward.

    I also changed it so that the Settings->General->Email-Address was the same as the user that was configured in the switft-smtp plugin.

    Other smtp plugins
    cimy
    https://www.cimatti.it/blog/cimy-wordpress-plugins/cimy-swift-smtp/
    or
    Coffee2Code SMTP plugin
    https://coffee2code.com/wp-plugins/configure-smtp/

    bret.miller

    (@bretmiller)

    You need a very small mod to class-phpmailer in wp-includes to support Google Apps. I wish I knew exactly where to suggest this to get it changed. In version 2.63, this starts at line 536 and reads:

    if(strstr($hosts[$index], ":"))
                    list($host, $port) = explode(":", $hosts[$index]);
                else
                {
                    $host = $hosts[$index];
                    $port = $this->Port;
                }

    To make it work for Google Apps, it has to support pulling the port off the end, but also allow for ssl:// at the start of the host name because ssl://smtp.gmail.com:465 is what works to connect. So here’s what you change it to:

    $i=strrpos($hosts[$index], ":");
    			if($i > 0) {
    				$host = substr($hosts[$index],0,$i);
    				$port = substr($hosts[$index],$i+1,strlen($hosts[$index])-$i);
    			}
                else
                {
                    $host = $hosts[$index];
                    $port = $this->Port;
                }

    Then you can use the wp-mail-smtp plugin to enable SMTP over ssl://smtp.gmail.com:465 and it just works.

    HTH,
    Bret

    Hi all Guys,

    i have a problem when using the mail() function to send mails in wp:

    https://rafb.net/p/DvMZkt74.html

    The error is here:

    MAIL FROM:<RadioDAnnata! <[email protected]>>

    MAIL FROM must be something like:

    MAIL FROM:<[email protected]>

    Because the sender name hasn’t to go there.

    Now i’ve solved using SMTP sending, so i think the problem is in the mail() function. I think this may be considered as a WordPress bug.

    Can you help me?

    Tips:
    1) You need to enable SSL in PHP.ini
    2) Unfortunately WordPress doesn’t give any message when SMTP is unsuccessful and seems to indicate it is. I had to hack /wp-includes/class-smtp.php inserting after this (Line 124 ):
    if(empty($this->smtp_conn)) {
    the following code:
    echo($errstr);die();

    This tutorial worked for me.
    Just remember to use ssl, the tutorial fails to mention that.

    hope it helps

    The “Cimy Swift SMTP” plugin worked for me on 2.7.1. It’s a new version of the old Swift SMTP plugin, but much more recent (updated in Feb 2009.) Here is the link:

    https://www.marcocimmino.net/cimy-wordpress-plugins/cimy-swift-smtp/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Gmail with a SMTP Plugin anyone?’ is closed to new replies.