Jump to content

Recommended Posts

Posted

Hi.

Just wanted to know how other PW people out there is dealing with sites that are in need of a newsletter system.

I am talking about a pretty simple solution for collecting emails and sending out newsletter / information to theese recipiens.

There are several forum threads that are dealing with this but not a really solid solution just suggestions and ideas.

Before when I did most of my sites in WP i often used plugnins like ACYmailer for instance something similar for PW would be so nice.

With PW I will have to use external providers like tinyletter / mailchimp, would be a Dream to have that fully integrated into PW.

I have started to build a own newsletter system but it is getting quite complex really fast if you want it to batch mails have different templates / recipiens Groups etc.

Like I said out of quriosity how is the forum dealing with this kind of functionality, for instance the PW news letter being sent out from Ryan witch system is powering that ?

Thankful for feedback !

/ Ronnie

Posted

Hi Ronnie,

Using a mail service to send is the best thing to do ( You can get easily banned on ip or IP range etc. ) 

On our Job we still use interspire emailmarketer. But we want to shift to MailChimp. I was busy with a fieldtype that creates a campaign & update it to mailChimp.

It's finished for 90% but I lack the time to finish the interrest groups. I will not bring sending within this module cause I think that can be done with a seperate module

If finished, I will share it with the PW community.

Posted

I wouldn't go near sending bulk emails from your own server as Martijn suggested. I have however toyed with using PW as a e-newsletter content creation tool for a couple of clients.

Regards

Marty
 

  • Like 1
Posted

We do the same as Marty.

We have several empty email templates. Pages with empty email templates may receive pages with content blocks, that way we can build a newsletter.

Then the source of the rendered newsletter is copied to the Newsletter Server.

  • Like 1
Posted
for instance the PW news letter being sent out from Ryan witch system is powering that ?

I'm embarrassed to admit that I send them myself, using a script I wrote more than a decade ago. It's always worked fine, so I've just stuck with it. But I agree with the guys that say it's better to use a service. Someday I will take that advice myself too. But if you want to use what I'm using, here you go…

First you'll need a text file with your subscribers in it. 1 email address per line. It can be only a few, or it can be thousands. 

subscribers.txt

bob@email.com
jim@bigcompany.com
mike@little-org.com

Now you'll need the email content. You'll want 1 HTML file and 1 text file. Both should have the same content:

template.html

<html>
<head>
<title>test email</title>
</head>
<body>
<h1>Test</h1>
<p>This is a test email</p>
</body>
</html>

template.txt

TEST
This is a test email

email.php

Place this PHP file in the same directory as the above files. Edit the DEFINEs at the top as necessary. I apologize in advance for this rather awful email solution, but hey it works, and that's why I haven't bothered to rewrite it in 10 years. :) To run, place the files on a web server and then load in your browser. It should start emailing immediately, once every 3 seconds. If you are sending thousands, then it might take several hours. But because it sends slow, it never seems to caught up in any filters. 

<?php

/**
 * GhettoMailer v1.0 
 *
 * © 1994 by Ryan Cramer
 *
 */

define("NAME_FROM",     '"Your Name Here"');
define("EMAIL_FROM",    "you@domain.com");
define("REPLY_TO",      "you@domain.com");
define("ERRORS_TO",     "you@domain.com");
define("SUBJECT",       "ProcessWire News & Updates - April/May 2013");

define("SECONDS", 3); // seconds delay between each email sent
define("TEXT_ONLY", false); // set to true if not sending HTML email
define("TEST_MODE", false); // set to true if just testing a send
define("TEST_MODE_EMAIL", "you@domain.com"); // email to send to when testing
define("SUBSCRIBERS_FILE", "subscribers.txt"); // file containing subscribers, 1 email per line
define("TEMPLATE", "template"); // file containing email to send: template.html and template.txt
define("X_MAILER", "GhettoMailer 1.0"); 

/**************************************************************************************/

ini_set("auto_detect_line_endings", true);

function mailTextHtml($to, $subject, $message_text, $message_html, $headers) {
  // exactly like regular mail function except sends both text and html versions
  
  $semi_rand = md5(time());
  $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
  $headers = trim($headers); // in case there is a trailing newline
  
  $headers .=               
    "\nX-Mailer: " . X_MAILER . "\n" .
    "MIME-Version: 1.0\n" .
    "Content-Type: multipart/alternative;\n  boundary=\"$mime_boundary\"";
  
  $message = 
    "This is a multi-part message in MIME format.\n\n" .
    "--{$mime_boundary}\n" .
    "Content-Type: text/plain; charset=\"utf-8\"\n" .
    "Content-Transfer-Encoding: 7bit\n\n" .
    "$message_text\n\n" .
    "--{$mime_boundary}\n" .
    "Content-Type: text/html; charset=\"utf-8\"\n" .
    "Content-Transfer-Encoding: 7bit\n\n" .
    "$message_html\n\n" .
    "--{$mime_boundary}--\n";
  
  $success = @mail($to, $subject, $message, $headers, "-f" . ERRORS_TO);
  return $success;
}

/**************************************************************************************/

$start = 0;
if(!empty($_GET['start'])) $start = (int) $_GET['start'];

$subscribers = file(SUBSCRIBERS_FILE);

if(isset($subscribers[$start])) {
  
  $line = trim($subscribers[$start]);
  $total = count($subscribers)-1;  
  $email = trim($line);
  $subject = SUBJECT;
  
  if(isset($_GET['pause'])) {
    $meta = '';
    $content = "[$start/$total] Paused. <a href=\"email.php?start=$start\">Resume</a><br />";

  } else {

    $meta = '<META HTTP-EQUIV=Refresh CONTENT="' . SECONDS . '; URL=./email.php?start=' . ($start+1) . '">';

    $content =   
      "[$start/$total] Emailing <u>$email</u><br />" .
      '<a href="email.php?pause=1&start=' . ($start+1) . '">Pause</a><br />';

    if(TEST_MODE) $email = TEST_MODE_EMAIL;

    $headers =   
      "From: " . NAME_FROM . " <" . EMAIL_FROM . ">\n" .
      "Reply-To: " . REPLY_TO . "\n" .
      "Errors-To: " . ERRORS_TO;

    $content .= "Subject: <b>$subject</b><br />";

    $bodyText = file_get_contents(TEMPLATE . ".txt");

    if(TEXT_ONLY) {
      mail($email, $subject, $bodyText, $headers, "-f" . ERRORS_TO);

    } else {
      $bodyHtml = file_get_contents(TEMPLATE . '.html'); 
      mailTextHtml($email, $subject, $bodyText, $bodyHtml, $headers); 
    }

    $handle = fopen("email.log", "a");
    if($handle) {
      fwrite($handle, "[$start/$total]: $email\n");
      fclose($handle);
    }
  }

} else {
  $meta = '';
  $content = "Subscriber emailing finished. $start emails sent.";
}

?>
<html>
<head>
<?=$meta; ?>
</head>
<body>
<?=$content; ?>
</body>

email.php

  • Like 5
  • 3 years later...
Posted
On 4/29/2013 at 9:57 PM, ryan said:

First you'll need a text file with your subscribers in it. 1 email address per line. It can be only a few, or it can be thousands. 

It should start emailing immediately, once every 3 seconds. If you are sending thousands, then it might take several hours. But because it sends slow, it never seems to caught up in any filters.

How I make a subscribe system for my website? I want to have a subscribe button with subscriber name and email address to collect their emails? I download NewsletterSubscription Module but it is not working or I did not properly configure that. 

Can I have an easy way like sending newsletters that Ryan explained above ?

Posted

These are two different things: subcriber system and newsletter sending.

I suggest to first read / post in the NewsletterSubscriptionModules forum support thread to get this working.

In regard to newsletter sending, I suggest to use a service and / or use a module like:

 

  • Like 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...