Forcing return-path in t3lib_htmlmail is now turned of by default. CAn be enabled...
authorJan-Erik Revsbech <jer@moccompany.com>
Sun, 10 Apr 2005 16:15:16 +0000 (16:15 +0000)
committerJan-Erik Revsbech <jer@moccompany.com>
Sun, 10 Apr 2005 16:15:16 +0000 (16:15 +0000)
Mailtesting in the install tool can now be done with t3lib_htmlmail instead of a direct call to mail().

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@616 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_htmlmail.php
t3lib/config_default.php
typo3/sysext/install/mod/class.tx_install.php

index 5f73f36..fe1195d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-04-10  Jan-Erik   <jer@moccompany.com>
+       * The earlier attempts to fix the problem of Return-Path with Postfix below version 2.0 seems not to work on all systems. The t3lib_htmlmail class now only forces the return-path if forceReturnPath is enabled in the install tool.
+       * Added an option to the install tool mail test form. Send the testmail via t3lib_htmlmail with the return-path set to null@<HTTP_HOST>.
+       
 2005-04-08  Michael Stucki  <michael@typo3.org>
 
        * Fixed bug #0000941: The diff feature was disabled on Windows but works fine if diff.exe is present and TYPO3_CONF_VARS[BE][diff_path] is correctly set
index da49bc0..074ee2a 100755 (executable)
@@ -247,26 +247,13 @@ class t3lib_htmlmail {
 
 
        /**
-        * Constructor for the class. Make a check to see if Postfix version below 2.0 is used.
-        * If this is the case all calls to mail() must not be called with the -f parameter to correctly set
-        * the Return-Path header.
+        * Constructor. If the configuration variable forceReturnPath is set, calls to mail will be called with a 5th parameter.
+        * See function sendTheMail for more info
         *
         * @return      [type]          ...
         */
        function t3lib_htmlmail () {
-               if(!ini_get('safe_mode')) {
-                       $res = Array();
-                       if(file_exists('/usr/sbin/postconf')) {
-                               @exec('/usr/sbin/postconf mail_version',$res);
-                               if(!empty($res[0])) {
-                                       $temp = explode("=",$res[0]);
-                                       list($major,$minor,$micro) = explode(".",trim($temp[1]));
-                                       if($major == 1) {
-                                               $this->postfix_version1 = true;
-                                       }
-                               }
-                       }
-               }
+               $this->forceReturnPath = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableReturnPath'];
        }
 
        /**
@@ -624,7 +611,7 @@ class t3lib_htmlmail {
         * For setting the return-path correctly, the parameter -f has to be added to the system call to sendmail.
         * This obviously does not have any effect on Windows, but on Sendmail compliant systems this works. If safe mode
         * is enabled, then extra parameters is not allowed, so a safe mode check is made before the mail() command is
-        * invoked. When using the -f parameter, some MTA's will put an X-AUTHENTICATION-WARING saying that
+        * invoked. When using the -f parameter, some MTA's will put an X-AUTHENTICATION-WARNING saying that
         * the return path was modified manually with the -f flag. To disable this warning make sure that the user running
         * Apache is in the /etc/mail/trusted-users table.
         *
@@ -633,8 +620,7 @@ class t3lib_htmlmail {
         *
         *  cannot handle command-line recipients with -t
         *
-        * This problem is solved by making a call to /usr/sbin/postconf mail_version and checking if the postfix is version
-        * 1.XX.YY If this is the case, the -f parameter is not used in the call to mail().
+        * The -f parameter is only enabled if the parameter forceReturnPath is enabled in the install tool.
         *
         * This whole problem of return-path turns out to be quite tricky. If you have a solution that works better, on all
         * standard MTA's then we are very open for suggestions.
@@ -653,7 +639,7 @@ class t3lib_htmlmail {
                                ini_set(sendmail_from, $this->returnPath);
                        }
                                //If safe mode is on, the fifth parameter to mail is not allowed, so the fix wont work on unix with safe_mode=On
-                       if(!ini_get('safe_mode') && !$this->postfix_version1) {
+                       if(!ini_get('safe_mode') && $this->forceReturnPath) {
                                mail($this->recipient,
                                          $this->subject,
                                          $this->message,
@@ -667,7 +653,7 @@ class t3lib_htmlmail {
                        }
                                // Sending copy:
                        if ($this->recipient_copy)      {
-                               if(!ini_get('safe_mode') && !$this->postfix_version1) {
+                               if(!ini_get('safe_mode') && $this->forceReturnPath) {
                                        mail(   $this->recipient_copy,
                                                                $this->subject,
                                                                $this->message,
@@ -684,7 +670,7 @@ class t3lib_htmlmail {
                        if ($this->auto_respond_msg)    {
                                $theParts = explode('/',$this->auto_respond_msg,2);
                                $theParts[1] = str_replace("/",chr(10),$theParts[1]);
-                               if(!ini_get('safe_mode') && !$this->postfix_version1) {
+                               if(!ini_get('safe_mode') && $this->forceReturnPath) {
                                        mail(   $this->from_email,
                                                                $theParts[0],
                                                                $theParts[1],
index 5597d26..40229de 100755 (executable)
@@ -74,6 +74,7 @@ $TYPO3_CONF_VARS = Array(
                'no_pconnect' => 0,                                             // Boolean: If true, "connect" is used instead of "pconnect" when connecting to the database!
                'multiplyDBfieldSize' => 1,                             // Double: 1-5: Amount used to multiply the DB field size when the install tool is evaluating the database size (eg. "2.5"). This is useful if you want to expand the size of fields for utf-8 etc. For western european sites using utf-8 the need should not be for more than twice the normal single-byte size (2) and for chinese / asian languages 3 should suffice.
                'setMemoryLimit' => 0,                                  // Integer, memory_limit in MB: If more than 16, TYPO3 will try to use ini_set() to set the memory limit of PHP to the value. This works only if the function ini_set() is not disabled by your sysadmin.
+               'forceReturnPath' => 0,                                 // Boolean: Force return path in mail() calls. If this is set, all calls to mail() done by t3lib_htmlmail will be called with '-f<return_path> as the 5th parameter. This will make the return-path correct on almost all unix systems. There is a known problem with postfix below version 2: Mails are not sent if this option is set and postfix is used. On windows platforms, the Return-Path is set via a call to ini_set. This has no effect if php safe_mode is on.
                'displayErrors' => -1,                                  // Integer, -1,0,1. 0=Do not display any PHP error messages. 1=Display error messages. -1=Default setting. With this option, you can override the PHP setting "display_errors". It is suggested that you set this to "0" and enable the "error_log" option in php.ini instead.
                'serverTimeZone' => 1                                   // Integer, GMT offset of servers time (from time()). Default is "1" which is "GMT+1" (central european time). This value can be used in extensions that are GMT aware and wants to convert times to/from other timezones.
        ),
index 751ebd9..97ff37e 100755 (executable)
@@ -1572,13 +1572,26 @@ From sub-directory:
                switch($cmd)    {
                        case "get_form":
                                $out='
-                               You can check the mail() function by entering your email address here and press the button. You should then receive a testmail from test@test.test.
-                               <form action="'.$this->action.'" method="POST"><input type="text" name="TYPO3_INSTALL[check_mail]">
+                               You can check the mail() function by entering your email address here and press the button. You should then receive a testmail from test@test.test.<br /> Since most mails from TYPO3 is sent using the t3lib_htmlmail class, sending with this class can be tested by checking the box <strong>Test t3lib_htmlmail</strong> below. The return-path of the mail is set to '."null@".t3lib_div::getIndpEnv("HTTP_HOST").'. Some mail servers wont send the mail if the host of the return-path is not resolved correctly.
+                               <form action="'.$this->action.'" method="POST"><input type="text" name="TYPO3_INSTALL[check_mail]"><br /><input type="checkbox" name="TYPO3_INSTALL[use_htmlmail]" >Test t3lib_htmlmail.
                                        <input type="submit" value="Send test mail"></form>';
                        break;
                        default:
                                if (trim($this->INSTALL["check_mail"])) {
-                                       mail(trim($this->INSTALL["check_mail"]), "TEST SUBJECT", "TEST CONTENT", "From: test@test.test");
+                                       if($this->INSTALL["use_htmlmail"]) {
+                                               require_once (PATH_t3lib.'class.t3lib_htmlmail.php');
+                                               $email = t3lib_div::makeInstance("t3lib_htmlmail");
+                                               $email->start();
+                                               $email->subject = "TEST SUBJECT";
+                                               $email->from_email = "Test@test.test";
+                                               $email->from_name = "Typo3 Install tool";
+                                               $email->returnPath = "null@".t3lib_div::getIndpEnv("HTTP_HOST");
+                                               $email->addPlain("TEST CONTENT");
+                                               $email->setHTML($email->encodeMsg("<html><body>HTML TEST CONTENT</body></html>"));
+                                               $email->send($this->INSTALL["check_mail"]);
+                                       } else {
+                                               mail(trim($this->INSTALL["check_mail"]), "TEST SUBJECT", "TEST CONTENT", "From: test@test.test");
+                                       }
                                        $this->messages[]= "MAIL WAS SENT TO: ".$this->INSTALL["check_mail"];
                                }
                        break;