Welcome Guest, Not a member yet? Register   Sign In
Sending multiple emails from my smtp-relay avoiding DoS
#1

We are sending emails each 4 hours 3 times per working day. 

After a certain quantity of sent emails (near 2000 every day, never an exact number), we are getting the following return starting with:
Code:
220 smtp-relay.gmail.com ESMTP u13-XXXXXXXXXXXXXX023asm946523vkl.5 - gsmtp
<br /><pre>hello: 421 4.7.0 Try again later, closing connection. (EHLO) .............


Studying the case, I've reached at https://support.google.com/a/answer/2956...ay-service :
[Image: DoS.png]


Taking a look in the email library in CI3 user guide in Email Preferences ( https://codeigniter.com/userguide3/libra...references ), I've found smtp_keepalive.
[Image: ci3-preference.png]

Does someone know if the goal of smtp_keepalive would solve the "connection caching" mentioned in Google documentation above? Otherwise, what would be the solution to configure this "connection caching" when sending emails using the email library in CI3?

Thank you!
Reply
#2
Wink 

I've found the solution. There is an error in system/libraries/Email.php in all CodeIgniter 3 versions.

The original snippet code is:
PHP Code:
    /**
    * Get Hostname
    *
    * There are only two legal types of hostname - either a fully
    * qualified domain name (eg: "mail.example.com") or an IP literal
    * (eg: "[1.2.3.4]").
    *
    * @link    https://tools.ietf.org/html/rfc5321#section-2.3.5
    * @link    http://cbl.abuseat.org/namingproblems.html
    * @return    string
    */
    protected function _get_hostname()
    {
        if (isset($_SERVER['SERVER_NAME']))
        {
            return $_SERVER['SERVER_NAME'];
        }

        return isset($_SERVER['SERVER_ADDR']) ? '['.$_SERVER['SERVER_ADDR'].']' '[127.0.0.1]';
    


The solution was:
PHP Code:
    /**
    * Get Hostname
    *
    * There are only two legal types of hostname - either a fully
    * qualified domain name (eg: "mail.example.com") or an IP literal
    * (eg: "[1.2.3.4]").
    *
    * @link    https://tools.ietf.org/html/rfc5321#section-2.3.5
    * @link    http://cbl.abuseat.org/namingproblems.html
    * @return    string
    */
    protected function _get_hostname()
    {
        if (isset($_SERVER['SERVER_NAME']))
        {
            return $_SERVER['SERVER_NAME'];
        }

        if (isset($_SERVER['SERVER_ADDR'])) {
            return '['.$_SERVER['SERVER_ADDR'].']';
        }

        $hostname gethostname();
        return '['.gethostbyname($hostname).']';
    


And you might ask "why", my answer is because we are running a PHP script code from CLI in remote server. When we try to send an email from localhost the current IP is almost always 127.0.0.1, but from a remote server this snippet code needs to get the public IP address to identify itself in "EHLO" to SMTP data.
Reply
#3

of course, you are right since an earlier thread you could not be detected between local and remote by the way that great
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#4

Please add an issue report to the CodeIgniter 3 Developers on GitHub.

CodeIgniter 3.x.x Development GitHub
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB