We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28042 ☆ A M B ☆
    • 24,524 Posts
    That line in the txnewsletters.class.inc.php file is
    $headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
    

    then the next line adds more to the headers. Unless I’m mistaken, the double newline should come at the end of the header, to separate it from the body of the email. I think that next line is an error; I’m not sure, but I think that is actually the body of the email and should not be included in the header.
    http://il.php.net/manual/en/function.mail.php

    Is anybody actually using this? It very much looks to me like it’s being sent with the "to" and the "message" in the headers! It’s supposed to be
    mail($to, $subject, $message, $headers);

    but the function in txnewsletters looks like this
    mail('', $subject,'', $headers);

    On top of that, the documentation has this to say:
    Note: It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.
      Studying MODX in the desert - http://sottwell.com
      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
      Join the Slack Community - http://modx.org
      • 26931
      • 2,314 Posts
      thanks Susan!

      removing the double newline still results in the same error
        • 26931
        • 2,314 Posts
        i changed
              $headers .= 'Content-Type: text/html; charset=UTF-8' ."\n";
              $headers .= 'Content-Transfer-Encoding: 8bit'. "\n\n";
              $headers .= $send_html . "\n";
              
              $result=mail('', $subject,'', $headers);

        to
              $headers .= 'Content-Type: text/html; charset=UTF-8' ."\n";
              $headers .= 'Content-Transfer-Encoding: 8bit';
              $message = $send_html;
              
              $result=mail($to, $subject, $message, $headers);

        ...and it seems to work, is this okay, does it make any sense? smiley
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Yes, although I believe that the $to is also being loaded into the headers, so it’s getting passed along as a cc or bcc. I would think that the $to should be in the first parameter to the mail() function, not incorporated into the $headers string. It’s possible you’ll be getting the mail twice, once from the $to, and once from the $headers.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 26931
            • 2,314 Posts
            although I believe that the $to is also being loaded into the headers, so it’s getting passed along as a cc or bcc
            thanks, i’ll look into that...it seems to be okay though

            @etal
            now that i managed to get the original TXNewsletter running, i tried your version and i got
            Error occurs during your subscription !You can go back to retry.
            when i subscribe

            any ideas what might be causing this?

            thanks, j

            *edit: i’m able to manually add subscribers, send emails and unsubscribe...just not to add through the signup form
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              I have no idea. To be honest, I’m just looking at the code here; I’ve never actually used this. Maybe there’s a reason why he had everything in the headers, and the double line feed was deliberate, to force the message out of the headers. But if your system is considering that to be a hack (which it is, and it can be used to force your innocent emails to become spammers or carry malicious payloads) then it won’t work for you.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 9130
                • 171 Posts
                Quote from: sharkbait at Aug 29, 2009, 08:21 AM

                @etal
                now that i managed to get the original TXNewsletter running, i tried your version and i got
                Error occurs during your subscription !You can go back to retry.
                when i subscribe

                any ideas what might be causing this?
                Did you add the new parameters (confirmEmail, secretCode, confirmEmailChunk) to the module configuration?
                What is are they set to?
                  • 26931
                  • 2,314 Posts
                  ...okay..i got it

                  around line line 1755 of txnewsletters.inc.php i needed to change $headers (like i did above) again

                  thanks everybody for helping me here smiley

                  *edit: to receive the confirmation-chunk, i actually needed to change txnewsletters.inc.php around line 1755 to:
                        $headers .= 'Content-Type: text/html; charset=UTF-8' ."\n";
                        $headers .= 'Content-Transfer-Encoding: 8bit';
                        $message = $html;
                        
                        $result=mail($to, $subject, $message, $headers);
                    • 26931
                    • 2,314 Posts
                    ..me again smiley

                    it happens that the newsletters will be sent to every newsletter-group, no matter what newsletter they signed up for...does anyone know how to fix this?

                    thanks, j
                      • 24935
                      • 160 Posts
                      You actually have to apply a filter in the management interface before sending your newsletter (just filter on the name of the newsletter that they signed up for).