We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39498
    • 169 Posts
    Is there any idea for sending bulk emails as multipart (plaintext and html)? Can t find anything. Buildet up htmlboilerplate + plaintextversions. Now looking for a good way to distribute. Better using a freeware client or integrate it into modx? Any pitfalls? Thanks for advices.
      • 3749
      • 24,544 Posts
      I can't remember if EmailResource has that option or not. It's definitely on the roadmap.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 39498
        • 169 Posts
        Ah, didnt see EmailResources before. I had a short view on the description and the code. I did not find any hint on sending bulk mail as multipart. I wonder, if it could be easily adopted (that means for a none-programmer like me) in that way: to give the bulk mailer two parts of the emailbody (already rendered html and plain text) and a recipients list as csv.
          • 3749
          • 24,544 Posts
          I just looked and multipart isn't there yet. However, adding this line at around line 298 of emailresource.class.php should fix that:

               $this->modx->mail->set(modMail::MAIL_BODY_TEXT, $this->html);


          The exact location doesn't matter as long as it's in the list with these lines:

                  $this->modx->mail->set(modMail::MAIL_BODY, $this->html);
                  $this->modx->mail->set(modMail::MAIL_FROM, $this->mail_from);
                  $this->modx->mail->set(modMail::MAIL_FROM_NAME, $this->mail_from_name);
                  $this->modx->mail->set(modMail::MAIL_SENDER, $this->mail_sender);
                  $this->modx->mail->set(modMail::MAIL_SUBJECT, $this->mail_subject);
                  $this->modx->mail->address('reply-to', $this->mail_reply_to);


          I haven't tested this, but it looks like it should work. PhpMailer should automatically strip the tags and format the text. You'll have to clear the cache after adding that line.


          I don't think ER will use your CSV user file (though that would be a nice feature). It sends to the members of a user group.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 39498
            • 169 Posts
            Thanks Bob,
            I now understand better. I had a deeper view on the ER scripts. Actually I consider, if I simply could build the $recipients array from an csv without running in any conflict with other parts of the script? And: are the item and batch delays to stabilize the bulk sending process? Would your recommend sending some hundreds of mails by that script, or better switch to a client bulk programm or a service e.g. mailchimp?
              • 3749
              • 24,544 Posts
              Probably the easiest and most reliable thing would be to write a little utility script that would read the CSV file, create the users, and add them to a user group.

              The item and batch delays are to keep from overwhelming the server (or ticking off your host, if you're on a shared server). I believe that there are people using ER for fairly large mailing lists, though MailChimp certainly has some nice features (e.g., bounce handling).

              BTW, you can use ER with MailChimp by using their "Email Beaming" feature and sending the ER test email to the address they give you.


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 39498
                • 169 Posts
                In another post I found ImportUsersX 1.0.1-pl, which handles the import of users, as its name says.

                Concerning the Plain Text Version I am not shure, if phpmailer strips Tags automatically. Found this in some docs:
                $mail->AltBody = strip_tags($email_text);
                . So if modmail doesn't do the job I have to stript tags seperately before I give it to modmail. And I wont have any basic asci text formating. I will test it and mabe try to implement the MAIL_BODY_TEXT from an own chunk.
                  • 3749
                  • 24,544 Posts
                  The tags should be removed automatically if you use the method I posted above with EmailResource (and I think there is some automatic formatting of the output as well). ER will also add inline CSS and adjust the image paths for any images and links to other pages on the site. There's also some adjustment for the poor CSS support in many mail readers.


                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html


                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 39498
                    • 169 Posts
                    Hi Bob, I wanted to give it a test on a newly build modx installation but failed at installing the component. Tried it several times on a blank installation. The install console gives me this messages without success at the end, seems to break the process:
                    Running PHP Resolver.
                    Assigning Events to Plugin EmailResource
                    Successfully assigned Events to Plugin EmailResource
                    Attempting to attach TVs to Templates


                    Closing the console and hitting the installbutton again:
                    Running PHP Resolver.
                    Assigning Events to Plugin EmailResource
                    Error 23000 executing statement: INSERT INTO `modx_site_plugin_events` (`pluginid`, `event`, `priority`, `propertyset`) VALUES (4, 'OnWebPagePrerender', 0, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '4-OnWebPagePrerender' for key 'PRIMARY' ) 
                    Successfully assigned Events to Plugin EmailResource
                    Attempting to attach TVs to Templates
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (25, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '25-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (14, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '14-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (15, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '15-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (16, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '16-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (17, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '17-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (18, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '18-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (19, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '19-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (20, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '20-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (21, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '21-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (22, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '22-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (23, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '23-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (24, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '24-1' for key 'PRIMARY' ) 
                    Error 23000 executing statement: INSERT INTO `modx_site_tmplvar_templates` (`tmplvarid`, `templateid`, `rank`) VALUES (26, 1, 0) Array ( [0] => 23000 [1] => 1062 [2] => Duplicate entry '26-1' for key 'PRIMARY' ) 

                    and stops again.
                      • 3749
                      • 24,544 Posts
                      I think those are "normal" errors. It's just telling you that those connections already exist. It may still work. Let me know.

                      Check to make sure that the TVs are connected to the correct Templates.


                      ------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using.
                      MODX info for everyone: http://bobsguides.com/modx.html


                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting