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
    You should be able to configure it to suit your site’s requirements.
      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
      • 2901
      • 277 Posts
      I believe so as well, I have tried to add

      $username=’’;
      and
      $password=’’;

      but no look. can you tell me which file is reading config.php, then I guess I will be able to find the suitable variables.
        • 2901
        • 277 Posts
        Ok I’ve tried to get this thing sending mails, no luck.

        I would really appreciate some help.

        thanks
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I really don’t know how to help; this is an embedded Koops Mailinglist, so he might be better able to help. It uses the Swift Mailer library, so maybe you can find what you need there.

          In the file admin.php, in the section for sending mail, line 55, it looks like you could change this to include the smtp_connection file instead, and use something like this:

          $smtp =& new Swift_Connection_SMTP("some-host.tld", 25);
          $smtp->setUsername("user");
          $smtp->setpassword("pass");
          $swift =& new Swift($smtp);


          However, this code is from the documentation for a newer version of Swift, so I’m not sure how it would work.
            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
            • 2901
            • 277 Posts
            Hi Susan
            thanks. I wrote him yesterday, but I have not yet an answer. However I will post it here in case that I get the problem solved.

            thanks again
              • 11429
              • 90 Posts
              how are you calling it in the page ?

              i have it setup but its not adding subscribers, i read one of the posts about uncaching it to get it to work but i did that and its still not adding subscribers
                • 5727
                • 160 Posts
                Hey, got my hands on this implementation of Koops MailingList, thanks to sottwell!

                Now, my client is using an external SMTP service which needs authentication. It seems people are having the same problem that I have had, so I’ll share my hacks here.

                Using SMTP server
                I’ve searched through every source files and it doesn’t seems like the config var $mailserver is used anywhere. At least, it doesn’t appear anywhere else than in the config.php file. So, anyways, I did a quick hack by modifying 2 lines in both functions.php and admin.php.

                First in functions.php, around line 71, I modified the source code to look like this:
                		if(($phpversion > 4)&&($phpversion < 5)){	
                			require('Swift/Swift.php');
                			require('Swift/Swift/Swift_Sendmail_Connection.php');
                			require('Swift/Swift/Swift_SMTP_Connection.php' );
                		}elseif($phpversion >=5){
                			require('Swift5/Swift.php');
                			require('Swift5/Swift/Swift_Sendmail_Connection.php');
                			require('Swift5/Swift/Swift_SMTP_Connection.php' );
                		}
                		$mail = new Swift(new Swift_SMTP_Connection('mail.yourhost.com'));
                		$mail->authenticate( 'smtp_username', 'smtp_password' );	

                So, as you can see, I added two lines to include the SMTP connection class and then modified the creation of the Swift object to use the SMTP class instead. You can also specify the server port and if you need SSL (second and third, optional) like this:
                $mail = new Swift(new Swift_SMTP_Connection('foo.bar.com', 9976, SWIFT_SSL);
                Other possible values for the third parameters are: SWIFT_OPEN (false/default), SWIFT_SSL (normal SSL), SWIFT_TLS (TLS/SSL).
                The $mail->authenticate() call is only required if your SMTP server requires authentication. Username first and password second.

                Now, same thing goes for the admin.php file, around line 55, here’s the changes I made:
                	case "2":
                	// automatically send newsletter
                		require('Swift/Swift.php');
                		require('Swift/plugins/Swift_Anti_Flood_Plugin.php');
                		require('Swift/Swift/Swift_Sendmail_Connection.php');
                		require('Swift/Swift/Swift_SMTP_Connection.php');		
                		$sql = "SELECT id, email FROM ".$prefix."subscribers";
                		$result = $modx->db->query($sql);		
                		$recipients = array();
                		while($newArray  = $modx->db->getRow($result)){
                			array_push($recipients, $newArray['email']);	
                		}
                		$mail = new Swift(new Swift_Connection_SMTP('smtp.yourserver.com'));
                		$mail->authenticate( 'username', 'password' );		
                		$text = str_replace('/UserFiles','http://'.$_SERVER['HTTP_HOST'].'/UserFiles', $_POST['FCKeditor1']);		
                


                Again, this is a dirty hack. Those parameters should probably go in the config.php file, but I hope this helps someone.

                More coming up.



                  Olivier Deland
                  Montreal, Canada - Web Developer
                  • 5727
                  • 160 Posts
                  Using the default RTE instead of FCKEditor
                  I hacked the admin.php file to make use of the RichText editor, as specified in the MODx config. This way, files and images uploaded for the mailing all go at the same place.

                  Here’s how I did it:

                  Edit the file admin.php, replace those lines:
                  		$oFCKeditor->FileBrowserLanguage = 'php' ;      // asp | aspx | cfm | lasso | perl | php | py
                  		$oFCKeditor->QuickUploadLanguage = 'php' ;      // asp | aspx | cfm | lasso | php
                  	#	$oFCKeditor->Height = '400';
                  		$oFCKeditor = new FCKeditor('FCKeditor1') ;
                  		$oFCKeditor->BasePath = '../assets/modules/koopsmailinglist/FCKeditor/';
                  		$oFCKeditor->ToolbarSet = 'mailform';
                  		$oFCKeditor->Create() ;

                  with this:
                  		// Get access to template variable function (to output the RTE)
                  		include_once($modx->config['base_path'].'manager/includes/tmplvars.inc.php');
                  	  
                  		$event_output = $modx->invokeEvent("OnRichTextEditorInit", array('editor'=>$modx->config['which_editor'], 'elements'=>array('tvmailMessage')));
                  	
                  		if(is_array($event_output)) {
                  			$editor_html = implode("",$event_output);
                  		}
                  		// Get HTML for the textarea, last parameters are default_value, elements, value
                  		$rte_html = renderFormElement('richtext', 'mailMessage', '', '', '');
                  		
                  		echo $rte_html;
                  		
                  		echo $editor_html;



                  This should output your default RTE in all its glory. Now, we still need to change something when we process the message. If you go a couple lines below, you’ll find this:
                  		$text = str_replace('/UserFiles','http://'.$_SERVER['HTTP_HOST'].'/UserFiles', $_POST['FCKeditor1']);


                  Comment it out and/or replace it with this:
                  		// convert [~ID~] urls 
                  		$text = preg_replace_callback(
                  			'!\[\~([0-9]+)\~\]!is',
                  			create_function(
                  				'$matches',
                  				'global $modx; return $modx->makeUrl($matches[1],\'\',\'\',\'full\');'
                  			), $_POST['tvmailMessage'], 1
                  		);
                  		
                  		// Make URLs absolute
                  		$text = preg_replace("@(<\s*(a|img)\s+[^>]*(href|src)\s*=\s*[\"'])(?!http)([^\"'>]+)([\"'>])@","$1".$modx->config['site_url']."$4$5",$text);


                  This will take the content from the RTE, and convert [~id~] links to full absolute URLs. It will also make sure that every img and link tags have proper, absolute URLs.

                  Hope this helps someone. grin
                    Olivier Deland
                    Montreal, Canada - Web Developer
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Thank you! I’ll test it out and if it works for me it’ll work for anybody, and I’ll update the version in the repository!
                      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
                      • 2901
                      • 277 Posts
                      Hi Folks

                      thanks a lot. I will try this as soon as possible.
                      Thanks again