2.52+ email tutorial?

7 posts by 2 authors in: Forums > CMS Builder
Last Post: May 6, 2013   (RSS)

By gkornbluth - April 25, 2013 - edited: April 25, 2013

Hi All,

I think that I’ve got the built in emails (like forgot password) being sent correctly by a SMTP server, and I might have missed it, but is there a tutorial about using the new email functionality built into 2.52+ to send emails created by viewers (web pages) by SMTP, like when an email needs to be sent to all users informing them of a particular event?

Also, I noticed that there is a check box in the “Outgoing Email” Log section called “Background Send” that indicates a Queued message to be sent by background mailer (for high-volume mail), but I don’t know how to set that up or where to insert the delayed mail parameters required I.E.: Message per hour, per day, messsage spacing required,etc.)

Here’s a pared down example of the type of message that I’d like to be able to send by SMTP, I just don’t know what changes I’ll have to make to the code, especially after the $mailArray code:

<?php $acceptance_email_message_1 = @$messagesRecord['acceptance_email_message_1'] ?>
      
<?php foreach($client_uploadsRecords as $record) : ?>
<?php $the_to = $record['email']; ?>
<?php $first_name = $record['first_name'] ; ?>
<?php $last_name = $record['last_name'] ; ?>
     
<?php
  $message = <<<EOF
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type content='text/html; charset=utf-8" />
<style type="text/css">
.special {font-family:Arial; color:  rgb(227,224,219); font-size: 1.0em; font-weight: bold; text-decoration: underline;}
.body-text {font-family:Arial; font-size: 1.0em;}
.body-text-yellow {font-family:Arial; color: rgb(255,255,0); font-size: 1.0em;}
.heading-text-yellow {font-family:Arial; color: rgb(255,255,0); font-size: 1.3em;}
</style>
</head>
<body bgcolor="#7C7164">
<table style='background-color: #7C7164;' width='100%' align='center' border='0' >
<tr>
<td align='left' >
<table style='background-color: #7C7164;' width='70%' align='center' border='0' >
<tr>
<td align='left' >
 <div align='left'>
<img src='http://www.artistsofpalmbeachcounty.org/exhibition_email_open.php?num=$recnum' height='1' width='1' alt='' />
<img src='http://www.artistsofpalmbeachcounty.org/images/APBC-LOGO.png' width='800' height='183' style='border:hidden'/></div>
<br /><br />
 <div align='left' class='body-text-yellow'>
Hello $first_name $last_name,
<br /><br />
 $acceptance_email_message_1
<br /><br />
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
EOF;
 $the_from  = "submissions@artistsofpalmbeachcounty.org";
 $the_subject = "Your entry has been accepted";

$mailArray = array(
'to' => $the_to,
'from' => $the_from,
'subject' => $the_subject,
'html'         => $message
);
$errors =  sendMessage($mailArray);
// delay execution by .2 sec
usleep(200000);
// reset max_execution_time to 30 sec
set_time_limit(30);
?>
<?php endforeach ?>

Thanks,
Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Thanks Dave,

I'm still a bit (a lot) confused about this, but willing to plug through it to get it to work...

That said, should I understand that:

A) I need to put any PHP including the EMAIL-TEST code into a new templates in order to use the functionality,

or,

B) I can to put that EMAIL-TEST code along with any other PHP code into a viewer?

or

C) I don't  understand this at all? "%$#@*"

Also, I'll probably have to send more than an allowable quantity of emails in one session, so to meet ISP requirements, I'll need to be able break the list down to predetermined quantities and schedule sending of each group.

If you could suggest the modifications required for the sample code above, I think I'll be able to get a better handle on this, and write up some docs that we can all follow.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - May 2, 2013

Hi Jerry, 

I'd start by putting the code above into a separate file and seeing if you can get it to send an email using a template.  If you can get it to do that you can then try adding the code to other php pages or viewers.  

>... so to meet ISP requirements, I'll need to be able break the list down to predetermined quantities and schedule sending of each group.

There's actually quite a bit of custom code required to do all of that.  I'm not really sure of a simple way to do it.

We were previously working on the "Background Send" feature where you could just write the emails to the "Outgoing Mail" table.  An early version of Newsletter Builder worked like that, but we'd end up using a lot of disk space and having things go slower then we wanted.

How many emails do you think you'd be sending in a batch and what's it for?  I'll see if I can think of any other ideas for you.

Thanks

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - May 4, 2013

Hi Dave,

That clears up a few questions and gives me a starting point.

I personally  like the idea of being able to code the contents of an email directly in my pages without having to us a complex series of placeholders and other code. Once I get into working with your suggestions, maybe that part will become more straightforward.

EMAIL SENDING (PLUGIN?)

I don't know how many emails there will be, since every client's needs are different. I can see the number going from a just hand full to thousands.

I'm sure that many of us (developers) would like to be able to have, (and would be willing to pay for) a robust mail plugin that handled the scheduling and sending of emails separate from the formatting and creation of those emails.

I hope that you'll decide to revisit the project soon.

BTW: The LBE E-mail scheduler is an interesting program for scheduling emails, but it has some HTML formatting issues that I was unable to solve.   http://www.lbetoolbox.com/scheduleemail.htm

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By Dave - May 6, 2013

Hi Jerry, 

I'm sure that many of us (developers) would like to be able to have, (and would be willing to pay for) a robust mail plugin that handled the scheduling and sending of emails separate from the formatting and creation of those emails.

I hope that you'll decide to revisit the project soon.

Thanks for the feedback.  I'll add making a plugin to do basic background mail sending to the list for the next release.  There's lots of issues that come up with mail sending, but it will let users try the background send functionality.

Have you had any luck sending a message from an email template yet? 

Cheers!

Dave Edis - Senior Developer
interactivetools.com

By gkornbluth - May 6, 2013 - edited: May 6, 2013

Thanks Dave,

No, not yet.

Life and work getting in the way. In addition to web design

I do some Audio and Audio for Video Post Production.

That's been my main focus for a lot of years, (before web design) and one of my client's has a deadline.

Back to it soon though.

Thanks for staying on top of this.

Jerry

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php