Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php into non-dynamic 1

Status
Not open for further replies.

HelenBN

IS-IT--Management
Dec 9, 2004
70
US
I use an open source web calendar program. I am looking for a way to use our SPAM compliant eMarketing service to set up a weekly email to announce things to do to the subscriber list. I can create a custom html page and get the calendar upcoming.php file the way I want it, but the service does not allow dynamic programming so the php content does not show.

Any ideas?????
 
sorry, Helen: I didn't ask the question well enough.

for the online interface how do you supply the html of the message that you want sent? do you upload a file or paste the html in?
 
I can upload an html file or paste in html code.
 
that gives us something to work with. the code below (once you put your template data into it) will create a ready made html file for you when you run it.

you can adapt this easily to run as a cron job (if you can set cron jobs on your server) and mail you the html file once per week.

Code:
<?php
$iFrameURL = "[URL unfurl="true"]http://www.theartscouncil.org/calendar/upcoming_eweek.php";[/URL]
$messageTemplate = "/path/to/template.html";
//assume that the template contains the following to show where the calendar should go
//[CALENDARGOESHERE]
$flag = "[CALENDARGOESHERE]";

//grab the templates into memory
//the calendar is grabbed dynamically
$calContents = file_get_contents($iFrameURL);
$message = file_get_contents($messageTemplate);

//get rid of unwanted tags in the calendar file
$start = strpos($calContents,"<body>");
$stop = strpos ($calContents, "</body>");
$calContents = substr($calContents, $start+6, $stop-$start -6);

//enclose the calendar in a nice css list box
//write the style information into the tag for cross-mail app compatibility
$calContents = <<<EOL
<div style="	height: 400px; 
				width: 400px; 
				margin: 0 auto; 
				overflow:auto; 
				border: thin black solid;">
	$calContents
</div>
EOL;

//assemble the html message
$message = str_replace($flag, $calContents, $message);

//now bung the message down the browser as an html file
header("Content-Type: application/octet-stream"); 
header("Content-Length: " .strlen($message));
header("Content-Transfer-Encoding: Binary"); // added
header("Content-Disposition: attachment; filename=\"htmlMessage.html\"");
echo $message;
?>
 
i should add that it might/should also be possible to automate the whole thing including the link to goDaddy but i do not have a GoDaddy account so cannot derive their interface.
 
(I've got that puzzled look on my face that my dog gets when I've asked him a question...)

I'm not sure what to do with what you have so graciously coded for me.
 
ah.

put in on a server that has php installed. any old directory so long as you remember where it is.

edit the template line
Code:
$messageTemplate="";
and put in the path to the html template that you use to build the email to send out, typically you could upload it to to the same directory and ideally it should be on the same webserver.

in the html template file make sure that you put the following in the place that you want the calendar to be
Code:
[CALENDARGOESHERE]

then every time you want to send a message out, point your browser at the script and you will receive a neatly formatted email to upload.

if goDaddy uses fields that are dynamically replaced with recipient's names etc then just include those fields as normal.

note - the difference between this method and the iFrame is that the content is static, so each time the email is opened by the user the same calendar data will be there. Your method would most likely have resulted in the content changing every time the user opened the mail as the underlying src of the iframe would change (the week-view is just a snap shot). Of course, every week that you run the script above, the content will change.

i've tried to emulate an Iframe by using a css vertically scrolling box. if you would rather have all the calendar items flat on the page, just take out the height and overflow style directives.

post back if you have trouble.
 
This is so cool. Now for another questions:

When I go to this page in IE, I get a file download question, do I want to open or save or cancel "htmlMessage.html."

When I click What's the risk? I get the following explaination:


Is it safe to open files that are downloaded from the Internet?
It depends. You should always treat files you download from the Internet with caution. Much depends on what you know about the file, its source, and its contents. Here are some ways to help make an informed decision about whether to open the file.

Look for warning messages. Internet Explorer displays a message when a website attempts to download a file to your computer. If the message contains a yellow caution icon, then the file has been identified as a type that could pose a risk because it might contain computer code (possibly a program or computer virus).
Scan the file with antivirus software before you open it. Save the file to your computer and then scan the file with an up-to-date antivirus program before opening it, rather than opening the file directly from the Internet.
Be more cautious with files that are not pictures, music, or plain text files. While pictures, music, or plain text file types (their names frequently end with one of these three-letter extensions: .jpg, .gif, .mp3, or .txt) are less likely to contain computer code or a virus, you should still be cautious with them. Look very carefully at the file name and extension because many viruses use double extensions, such as mypictures.jpg.exe, to trick people into running them. With all other file types, you should be even more cautious.
It might be safe to open the file if all of the following are true:

When you run the file from the download dialog box, the message shows the publisher's name. If the publisher cannot be identified, it is safer to delete the file unless you know who created it and what it will do to your computer.
You completely trust the publisher. For example, if you have received files from this publisher before or they were recommended by a trusted person.
You requested the file. If a file starts downloading automatically or is offered when you didn't specifically request it, cancel the download.


Is this IE's problem? I will put a link for non-html email users to view it online if they are having trouble seeing it. I guess the optional view can be the iframe one so this warning won't scare them off.

What do you think?
 
ummm... you just download the file to your hard drive and then when you log on to goDaddy you upload the file as the message body. hopefully goDaddy should take the file and send it as the body rather than as an attachment. is that what is happening?

otherwise i will reconfigure the script to give you the source code rather than a file.
 
yes, I didn't have a problem with it. I know to trust myself. But we still have to make allowances for the email users that do not have the ability to receive html based email, so I have to have the first line "If you can't read this then click here." So, what I was saying is that I will STILL have my iframe template uploaded and that will be the optional online view for those few email users.

(Maybe you didn't need to know that... sorry.)

This is a great solution. Thank you for helping me.

Unfortunately, I have to "time" the generation of this file, so I cannot set up my eMarketing in advance. Unless I use a cron job. But I would still have to download the file and build the email. So is there anything else I can do or have you done it all?
 
honestly - i have not seen the goDaddy interface and i have not been able to find an API. If they have an API or we could derive it from their interface, then you could automate the whole thing.

i would assume that goDaddy provide different fields for you to input plaintext content and html content and then send the email as multi-part/alternative?

when you say you have to "make allowances for users" do you mean that the users may have to download the htmlemail.html file? that was not my intention. I'm sensing we are talking about different things slightly since i would have thought the solution I posted would take the place of the iFrame variation.

This is the frustration of forums: i'd bet that a telephone conversation would sort out any mutual misunderstanding in a couple of minutes! Feel free to try me: my number is on my website:
 
forums are sssoooo fun... :)

If I send a text version of my nicely designed email, for those using archaic webmail or they are too paranoid to get html email, they get this:


If you are having trouble viewing this e-mail, click here ( ) .



Upcoming Events

Monday, January 29, 2007 Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Tuesday, January 30, 2007 Zeuxis: Facets of Perception ( ) Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Wednesday, January 31, 2007 Zeuxis: Facets of Perception ( ) Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Thursday, February 1, 2007 Marie Gobble Levine at WVTF Gallery ( ) (9:00am) Art by Night ( ) (5:00pm)
Zeuxis: Facets of Perception ( ) Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Friday, February 2, 2007 That Film and Coffee Thing at the Art Museum - Rabbit Proof Fence ( ) (5:30pm)
Zeuxis: Facets of Perception ( ) Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Marie Gobble Levine at WVTF Gallery ( ) (9:00am) Saturday, February 3, 2007 Zeuxis: Facets of Perception ( ) Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Marie Gobble Levine at WVTF Gallery ( ) (9:00am) Sunday, February 4, 2007 Grand Celebration at Roanoke's Grand Hotel ( ) (12:30pm) Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Marie Gobble Levine at WVTF Gallery ( ) (9:00am) Monday, February 5, 2007 Art in the Office ( ) (All day event) Art in the Window I ( ) (All day event) Art at FNB ( ) (All day event) Marie Gobble Levine at WVTF Gallery ( ) (9:00am)

To view more events, visit the Cultural Calendar ( ) .

(c) 2007 The Arts Council of the Blue Ridge ( ) . All rights reserved.


That's enough to make anyone pull out their hair. That's why I have to have that first line in there with an alternate view. So what you coded will work just fine.

I don't think you can view the goDaddy eMarketing without an account, but here's where you can see some screen shots:


and


I will send you both the samples to your email on your site.

Maybe that will help.
 
thanks. i can't see a better way other than not including the hyperlinks in the text only version. that, at least, would cause it to read better!

i don't think that screen shots will help as it is the source code of the final form that will be important to see whether an API can be derived.
 
I think we have exhausted the possibilities. Thank you so much. If you can think of anything else, let me know!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top