CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 newsletter

Print topic Send  topic

Author Message
gerrit


Posts: 131
Posted: 05/02/2006, 11:25 AM

hi,

I looking for a example of a newletter system make's in codecharge studio ( php )

Can anybody help me !!

Greetz.
_________________
| http://www.vision.to |
View profile  Send private message
Damian Hupfeld
Posted: 05/02/2006, 4:49 PM

Gerrit,

The part everyone has difficulty with is the sending to the subscribers as
CCS doesnt have any inbuilt methods to send the same email to multiple users
without using CC or BCC which are not ideal.

I posted a script elsewhere in this forum that I use to do teh actual
sending but it is a little convoluted. The rest of the newsletter is done in
CCS.

Damian


"gerrit" <gerrit@forum.codecharge> wrote in message
news:54457a40af339b@news.codecharge.com...
> hi,
>
> I looking for a example of a newletter system make's in codecharge studio
> ( php
> )
>
> Can anybody help me !!
>
> Greetz.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

mamboBROWN


Posts: 1713
Posted: 05/02/2006, 7:42 PM

gerrit,
I actually disagree with Damian, there is a way to do it in CCS but what can be tricky is how you actually execute the email command and how many subscribers you have. Here are three suggestions. I have successfully used the first one (300+ users).

Suggestion 1(short list of subscribers):
You could have a page that when executed (before show) it would read a subscriber list (table) and send the email to each and every individual subscriber (you will need to use a loop to send the email). The only catch is that your screen will be frozen until it actually completes sending the email (you could avoid this by having the screen be a popup screen) or your execution time (php.ini: max_execution) elapses which would cause the command to terminate. It usually is set to 30 seconds (I increased mine to 90 seconds).

Suggestion 2:
This one is a little more involved (and be careful of server load) but it definitely can be done (it is also probably one of the more popular ways of sending bulk email). I am currently in the process of putting this one together (invoicing system). Take the same code above and with some more modifications and have a cron job execute it at specific times of the day or have it so that a flag is set so that when the cron job runs it will know if to send the email messages.

Suggestion 3:
There actually is a third one but I am still investigating it. It actually allows you to execute code in the background without actually freezing your screen almost like a cron job.

Hopefully this is helpful to you.
View profile  Send private message
Damian Hupfeld
Posted: 05/02/2006, 9:12 PM

MamboBrown,

I am basically doing option 1 but the building of the email list and the
looping is done via an external file. It could probably all be put into a
Custom Code within the page but there was still a fair bit of manual coding
to do. The newsletter content is all made from CCS pages.

Are you willing to share the code that you use? My code is as follows:

<?php
//Send Email
$newsid=$_GET['id'];
$newsname=$_GET['name'];
$conn = mysql_connect('localhost', 'mysqlusername', 'mysqlpass');
if (!$conn) {
echo "No connect";
die('Could not connect: ' . mysql_error());
}

mysql_select_db('mysqldatabase');
//Build Recpient List

$sql="SELECT * FROM email";

$result = mysql_query($sql);
ini_set("SMTP", "localhost");
//Get HTML content from file
$content = "http://www.itng.com.au/newsletter.php?id=".$newsid;
$messagehtm = implode("", file($content));
while (strlen($messagehtm) < 300){
$messagehtm = implode("", file($content));
}
//Get Plain content from file
$content = "http://www.itng.com.au/newstext.php?id=".$newsid;
$messageptx = implode("", file($content));
while (strlen($messageptx) < 300){
$messageptx = implode("", file($content));
}
//$messageptx = "Plain Text version";
//Create a new log file in logs directory
$fname2 = date("ymdiH").".txt";
$fname = "logs/". $fname2;
$fp = fopen($fname, "a") or die("Couldn't create new file");
fwrite($fp, "Newsletter Name= ".$newsname." - Sent on ". date("d M y")." At
". date("H:i"));

while ($row = mysql_fetch_assoc($result)) {
$to =$row['email_address'];
//Prepare Mail
$subject = $newsname;

if ($row['email_type']=="0") {
$message=$messageptx;
$etype = "plain";
} else {
$message=$messagehtm;
$etype="html";
}
$from = "Damian Hupfeld <newsletter@itng.com.au>";
$additional_headers = "From: $from\nReply-To: $from\nContent-Type:
text/html";
//Send Mail
mail ($to, $subject, $message, $additional_headers,"-f
newsletter@itng.com.au");
//Add to log file
fwrite($fp, "\r\nSent to ".$to." - ". $etype);
usleep(25000);
}
ini_restore("SMTP");
//Close log file
fclose($fp);
$sql9="Update news Set news_log='$fname2' Where news_id=$newsid";
mysql_query($sql9);
//echo $sql9;
?>
<html>
<body>
Your Newsletter is now being Mailed.<br/>
<a href="http://www.itng.com.au/news_list.php">Back</a>
</html>

Damian



"mamboBROWN" <mamboBROWN@forum.codecharge> wrote in message
news:54458188556f8b@news.codecharge.com...
> gerrit,
> I actually disagree with Damian, there is a way to do it in CCS but what
> can be
> tricky is how you actually execute the email command and how many
> subscribers
> you have. Here are three suggestions. I have successfully used the first
> one
> (300+ users).
>
> Suggestion 1(short list of subscribers):
> You could have a page that when executed (before show) it would read a
> subscriber list (table) and send the email to each and every individual
> subscriber (you will need to use a loop to send the email). The only
> catch is
> that your screen will be frozen until it actually completes sending the
> email
> (you could avoid this by having the screen be a popup screen) or your
> execution
> time (php.ini: max_execution) elapses which would cause the command to
> terminate. It usually is set to 30 seconds (I increased mine to 90
> seconds).
>
> Suggestion 2:
> This one is a little more involved (and be careful of server load) but it
> definitely can be done (it is also probably one of the more popular ways
> of
> sending bulk email). I am currently in the process of putting this one
> together (invoicing system). Take the same code above and with some more
> modifications and have a cron job execute it at specific times of the day
> or
> have it so that a flag is set so that when the cron job runs it will know
> if to
> send the email messages.
>
> Suggestion 3:
> There actually is a third one but I am still investigating it. It
> actually
> allows you to execute code in the background without actually freezing
> your
> screen almost like a cron job.
>
> Hopefully this is helpful to you.
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

mamboBROWN


Posts: 1713
Posted: 05/02/2006, 9:59 PM

Damien,
I'll see what I can do about posting the code.
View profile  Send private message
gerrit


Posts: 131
Posted: 05/03/2006, 12:06 AM

Hi,

It is not simple to make dis for me.
It is possible that there is someone newsletter project wants share with me (Suggestion 1(short list of subscribers): ).
I have not yet this way much experience with code charge studio.

_________________
| http://www.vision.to |
View profile  Send private message
lwismanuel


Posts: 39
Posted: 05/03/2006, 5:36 AM

Quote :
Suggestion 3: There actually is a third one but I am still investigating it. It actually allows you to execute code in the background without actually freezing your screen almost like a cron job.
mamboBROWN, that is called PHP forking. Here it goes a tutorial
http://www.phpfreaks.com/tutorials/71/1.php
I hope that helps.

Luis
View profile  Send private message
mamboBROWN


Posts: 1713
Posted: 05/03/2006, 9:38 AM

lwismanuel
Thanks alot for the tutorial link. It is very helpful.
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.