commit 27ba7d12b2bad59d66987019b356e2f66b774be4
parent b5d1d0085cd9234ba798d8abfbfcb6b75f5f24a0
Author: dankert <devnull@localhost>
Date: Sat, 17 Nov 2007 17:55:18 +0100
Abfangen, wenn E-Mail ung?ltig oder kein MX-Host vorhanden ist.
Diffstat:
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/serviceClasses/Mail.class.php b/serviceClasses/Mail.class.php
@@ -73,7 +73,7 @@ class Mail
* @param String unbenutzt.
* @return Mail
*/
- function Mail( $to='',$text='common',$xy='' )
+ function Mail( $to,$text,$xy='' )
{
global $conf;
@@ -174,7 +174,7 @@ class Mail
// Die E-Mail wurde nicht akzeptiert.
// Genauer geht es leider nicht, da mail() nur einen boolean-Wert
// zurück liefert.
- $error = 'Mail was NOT accepted.';
+ $this->error[] = 'Mail was NOT accepted by mail()';
return false;
}
@@ -185,13 +185,21 @@ class Mail
if ( !empty($smtpConf['host']))
{
+ // Eigenen Relay-Host verwenden.
$mxHost = $smtpConf['host'];
$mxPort = intval($smtpConf['port']);
}
else
{
+ // Mail direkt zustellen.
$mxHost = $this->getMxHost($this->to);
+ if ( empty($mxHost) )
+ {
+ $this->error[] = "No MX-Entry found. Mail could not be sent.";
+ return false;
+ }
+
if ($smtpConf['ssl'])
$mxPort = 465;
else
@@ -461,9 +469,15 @@ class Mail
*/
function getMxHost( $to )
{
- $part = explode('@',$to);
- $part = explode('>',$part[1]);
- $host = $part[0];
+ list($user,$host) = explode('@',$to.'@');
+
+ if ( empty($host) )
+ {
+ $this->error[] = 'Illegal mail address - No hostname found.';
+ return "";
+ }
+
+ list($host) = explode('>',$host);
$mxHostsName = array();
$mxHostsPrio = array();