xref: /plugin/smtp/helper.php (revision ae907de1f1f7424d2984dffc04bc413eb0a30567)
14dc22474SAndreas Gohr<?php
24dc22474SAndreas Gohr/**
34dc22474SAndreas Gohr * DokuWiki Plugin smtp (Helper Component)
44dc22474SAndreas Gohr *
54dc22474SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
64dc22474SAndreas Gohr * @author  Andreas Gohr <andi@splitbrain.org>
74dc22474SAndreas Gohr */
84dc22474SAndreas Gohr
94dc22474SAndreas Gohr// must be run within Dokuwiki
104dc22474SAndreas Gohrif(!defined('DOKU_INC')) die();
114dc22474SAndreas Gohr
124dc22474SAndreas Gohrclass helper_plugin_smtp extends DokuWiki_Plugin {
134dc22474SAndreas Gohr
1427827474SAndreas Gohr    /**
1527827474SAndreas Gohr     * Return a string usable as EHLO message
1627827474SAndreas Gohr     *
1727827474SAndreas Gohr     * @param string $ehlo configured EHLO (ovverrides automatic detection)
1827827474SAndreas Gohr     * @return string
1927827474SAndreas Gohr     */
2027827474SAndreas Gohr    static public function getEHLO($ehlo='') {
2127827474SAndreas Gohr        if(empty($ehlo)) {
22*ae907de1SMoritz Raguschat            $ip = $_SERVER["SERVER_ADDR"];
23*ae907de1SMoritz Raguschat            if (empty($ip))
24*ae907de1SMoritz Raguschat              return "localhost.localdomain";
25*ae907de1SMoritz Raguschat
26*ae907de1SMoritz Raguschat            // Indicate IPv6 address according to RFC 2821, if applicable.
27*ae907de1SMoritz Raguschat            $colonPos = strpos($ip, ':');
28*ae907de1SMoritz Raguschat            if ($colonPos !== false) {
29*ae907de1SMoritz Raguschat                $ip = 'IPv6:'.$ip;
30*ae907de1SMoritz Raguschat            }
31*ae907de1SMoritz Raguschat
32*ae907de1SMoritz Raguschat            return "[" . $ip . "]";
3327827474SAndreas Gohr        }
3427827474SAndreas Gohr        return $ehlo;
3527827474SAndreas Gohr    }
364dc22474SAndreas Gohr
374dc22474SAndreas Gohr}
384dc22474SAndreas Gohr
394dc22474SAndreas Gohr// vim:ts=4:sw=4:et:
40