Browse Source

FIX: A constructor must not return a value.
FIX: A topic is required to send an email (probability to be spam of
99%)

Laurent Destailleur 9 years ago
parent
commit
6033b09344
1 changed files with 8 additions and 2 deletions
  1. 8 2
      htdocs/core/class/CMailFile.class.php

+ 8 - 2
htdocs/core/class/CMailFile.class.php

@@ -134,6 +134,13 @@ class CMailFile
 		dol_syslog("CMailFile::CMailfile: MAIN_MAIL_SENDMODE=".$conf->global->MAIN_MAIL_SENDMODE." charset=".$conf->file->character_set_client." from=$from, to=$to, addr_cc=$addr_cc, addr_bcc=$addr_bcc, errors_to=$errors_to, trackid=$trackid", LOG_DEBUG);
 		dol_syslog("CMailFile::CMailfile: subject=$subject, deliveryreceipt=$deliveryreceipt, msgishtml=$msgishtml", LOG_DEBUG);
 
+		if (empty($subject))
+		{
+            dol_syslog("CMailFile::CMailfile: Try to send an email with empty subject");
+            $this->error='ErrorSubjectIsRequired';
+            return;
+		}
+
 		// Detect if message is HTML (use fast method)
 		if ($msgishtml == -1)
 		{
@@ -436,8 +443,7 @@ class CMailFile
 		{
 			// Send mail method not correctly defined
 			// --------------------------------------
-
-			return 'Bad value for MAIN_MAIL_SENDMODE constant';
+            $this->error = 'Bad value for MAIN_MAIL_SENDMODE constant';
 		}
 
 	}