Now when I send out a mass email my program desplays the emails it has sent out to and also gives me the total number of what was sent out. What I want to do is save that page that was dynamically created.
This is what the generated page looks like
-----------------------------------------------------------------------
(1.) Sent out E-Mail to mail1@domain1.com
(2.) Sent out E-Mail to mail2@domain2.com
(3.) Sent out E-Mail to mail3@domain3.com
(4.) Sent out E-Mail to mail4@domain4.com
(5.) Sent out E-Mail to mail5@domain5.com
(6.) Sent out E-Mail to mail6@domain6.com
(7.) And so on and so on
The E-Mail was sent out to a total of 7 E-Mails.
-----------------------------------------------------------------------
Now I want to be able to save that page. I would like it to be named after the date of when it was created. Like so
-----------------------------------------------------------------------
10-19-01.htm or something similar
-----------------------------------------------------------------------
That way my customers can check and see that there mail was sent out to a total of # users and the date of when it was sent out.
Is there anyway I can do this?
Thanks for any help given.
From what I can tell, I assume the following (correct me if I'm wrong):
so these two elements would be the dynamic part of your result page.
In pseudocode, it could look like this:
// send your message and mark sent email
For each email in your DB {
send message to email
add email to EmailSentArray
increase Counter
}// set your report header (html code)
report = "<HTML>.....<BODY><H2>Mail out report for:" + date + "</H2>";// display result page and build report
For each email in EmailSentArray {
htmlEmail = ArrayIndex + " Sent out E-Mail to " + email + "<BR>";
display(htmlEmail);
report = report + email;
}// display total
footer = "<P>The E-Mail was sent out to a total of " + Counter + " E-Mails.</P></BODY></HTML>";
display(footer);
report = report + footer;// output report to disk
filename = format(date) + ".html";
create file (filename);
write to file (filename, report);
hope that helps
mavherick
I have got it all working. I had the code done for sending the mail in PHP. I just needed to figure out a way to save the output for later use.
So I went ahead and used output buffering to do the work of grabbing ahold of the data I needed and then had it write into a file that I manage to name after the time and date. I also had it create a folder for each client so that I may keep it as clean as possible. I'm very proud of this piece of work and I hope to make it even better.
Here is some of the code used incase your curious.
// Check and see if directory already exist or if we have to create one // The name of the directory to be created
$foldername = $client_name;
// Where the directory will be created
$dir_mapping = "$foldername";
// Get date to name file
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
$hours = $today['hours'];
$minutes = $today['minutes'];
$seconds = $today['seconds'];
// Name file
$filename = "$hours:$minutes:$seconds-$month-$mday-$year.htm";
// If it exists open the directory
$dir = opendir("/home/sites/home/web/MailingList/mail-admin/".$dir_mapping);
while ($file = readdir($dir)) {
$file = chdir("/home/sites/home/web/MailingList/mail-admin/".$foldername);
// Create file
$fp = fopen ($filename, "w")
or die("Couldn't open $filename");
// Write to HTML file
fwrite ($fp, ob_get_contents());
// Close file
fclose ($fp);
}
// Close directory
closedir($dir);