Location: PHPKode > scripts > Mail Send Addon for Drupal Simplenews Newsletter > read_me.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Send Mail Read Me</title>
<style type="text/css">
.bold {
	font-weight: bold;
}
.red {
	color: #F00;
}
</style>
</head>

<body>
<p><span class="bold">General</span><br />
  <br />
Recently I had some problems when sending e-mails with simplenews newsletter module for Drupal. While this is a very good module, sometimes made Drupal cron to fail and stuck. I also wanted full control on sending mails and  to avoid some of the limitations of Drupal cron timings. Since I didn't have the time to enhance the simplenews module I did this script to be sure that my mails are sent. <span class="bold">This script needs <a href="https://drupal.org/project/Simplenews‎" target="_blank">simplenews newsletter module</a> and Drupal in order to work.</span> It has been tested with Drupal 7 (but should work on any version) and simplenews 7.</p>
<p><br />
  <strong>How it works</strong><br />
  <br />
You only need the php file and a form that will initiate it plus a custom unsubscribe page. The script uses simplenews newsletter database tables, users, newsletter categories etc. The only thing you have to do is to <strong>disable the simplenews newsletter spool cron</strong> from Drupal cron in order to avoid having both this tool and Drupal cron sending mails or publish your newsletter but choose not to send them from Simplenews/Drupal interface. You can easily dissable simplenews cron with the <a href="https://drupal.org/project/elysia_cron‎" target="_blank">Elysia Cron</a> module for Drupal.  Users will continue to subscribe/unsubscribe using simplenews newsletter module and you will create the newsletters the usual way. The script works with multiple newsletter categories and every time processes the latest newsletter that has not been sent. After you sent the newsletter, there is nothing else you need to do, spool tables are cleared and newsletter will be marked as sent in your Drupal site.  When you are ready to send just call this php file with form submission (<strong>see form_example.html</strong>). This form will post a username and password (for extra security) to the php file and the process will start.</p>
<p><strong>The custom unsubscribe page</strong></p>
<p>Since we are sending e-mail oustide Drupal and Simple news framework we create a new unsubscribe link that is sent to all users. You can use the <strong>unsubscribe.php</strong> as example or as is. Simplenews unsubscribe functions still work as well but we need this file/url since we create a new type of unsubscribe URL that is send with mails. You have to declare the path for your new unsubscribe page ine the main php file and also set some settings in <strong>unsubscribe.php</strong> or how you will name it. You can even copy the php code to a <strong>Drupal page</strong> -you have to enable php in text editor from Drupal modules/settings- in order to have site-wide look and feel.<br />
  <br />
<strong class="red">When sending mails you should not close the sending browser window</strong>. The page refresh it’s self in order to send the number of mails every some seconds based on your settings. After every iteration you will see the results (number of iterations, remaining e-mails), countdown to next iteration and any mail errors at the end. If you close the window before the process ends and resubmit the initiation form, all mails will be resent.</p>
<p><span class="bold"><br />
  Settings - Instalation</span><br />
  <br />
In the main php file you will have to set a few things, like the database connection details for your Drupal installation and username and password to run the script plus the stepping for mailing (how many mails every how many seconds will be sending) and the unsubscribe URL.</p>
<p>In your unsubscribe page you just have to set database connection details.<br />
</p>
<p>In your form <span class="bold">(the php script should be called from a form</span>) set the form action URL to mach your renamed php file and submit the username and password you have set in php file. There is a footer text field in the form. You can<span class="bold"> add there the urls for online view of message</span>. You can use the drupal node URL of the newsletter you will send.</p>
<p> This form can be added as a Drupal page that only admins have access (enable full HTML at Drupal text editor) so you can send your e-mails from your Drupal admin site.</p>
<p>After you do your settings put you form somewhere (even in your computer, or as a secured Drupal page -unpublished, available only to admins-), upload the php file set the unsubscribe page and you are done.<br />
  <br />
</p>
<p><span class="bold">Testing</span></p>
<p>  To test the script, the simplest way is, to create a test newsletter category add a few e-mail addresses as subscribers, create a newsletter in this category, all with simplenews newsletter module and Drupal. Then  send your newsletter with the initiation form and this php script.<br />
</p>
<p class="bold"><br />
Securtiy Tips</p>
<p>You should have no security issues with this sript as it runs outside Drupal, but here are some thing you should do.<br />
</p>
<p>-Rename the main php file and do not add a public link to it<br />
  -Set script username and password in php file<br />
  -Add the initiation form to a Drupal page available only to admins,  it can be an unpublished page.<br />
  <br />
Even if someone runs the script, will just sent an unsent newsletter. If all your newsletters have been sent nothing will happen (probably) :-)</p>
<p><br />
For latest version and support visit 
  <a href="http://tecorange.com/content/mail-send-addon-drupal-simplenews-newsletter">http://tecorange.com/content/mail-send-addon-drupal-simplenews-newsletter</a><br />
</p>
<p><em>Thank you :-)</em></p>
<p>This is a free script from <a href="http://tecorange.com" target="_blank">TECOrange.com</a> provided “as is” without any kind of warranty. If you think this is good <a href="http://tecorange.com" target="_blank">visit the page</a>, share it, subscribe to newsletter or <a href="http://www.twitter.com/tecorange" target="_blank">follow at twitter</a> to find a lot of useful things around Web and Mobile Development, Project Management, SEO, SEM and more :-)<br /><br />
  For more details about this script and support <a href="http://tecorange.com/content/mail-send-addon-drupal-simplenews-newsletter" target="_blank">visit the mail send addon for drupal Simplenews newsletter page</a>.<br />
</p>
</body>
</html>
Return current item: Mail Send Addon for Drupal Simplenews Newsletter