Welcome Guest, Not a member yet? Register   Sign In
Sending multiple emails from my smtp-relay avoiding DoS
#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


Messages In This Thread
RE: Sending multiple emails from my smtp-relay avoiding DoS - by rodrigoguariento - 01-04-2023, 03:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB