Gossamer Forum
Home : Products : DBMan : Customization :

Stand Alone Mass Email Script Mod: Beta Version

(Page 1 of 2)
> >
Quote Reply
Stand Alone Mass Email Script Mod: Beta Version
Dear DBMAN Users, Programmers, and Household Pets,

Okay...I know that this particular mod has been requested by many DBMAN users. I have a beta version of a script that will hopefully accomplish this goal.

I have made it as user friendly as possible. I know that there is room for improvement. I do in the future plan on adding the following features:

1) Work with DBMAN Template System
2) Set up fields in array for sending out more targeted email messages to Database users.
3) Enhanced Logging functions.
4) Web Based Administration to customize messages and choose users to send email.
5) Allow Database Users to "subscribe" via their database forms (add, modify, delete).

Right now, the only thing that the script does is compare two fields (Email and User-Defined Field, like Year Graduated or Member of a Certain Group or Category), and then sends out an email message to all those users. This script can be executed as a cron job for UNIX or scheduled job for NT, or executed via your web browser.

I admit that this script is very rudimentary and lacks a lot of bells and whistles. But based on the number of requests for this type of script, I thought I would release it in its infantile and beta stage.

Please provide comments about this mod. Download it and test it!

It is located at the following URL:

www.anthrotech.com/cgi/dbman/mods/mailer.txt

I am willing to assist DBMAN users with configuring the script to fit their personal database needs. Please post your comments, suggestions, and technical problems in this Thread, and I will do my best to help you.

I hope this works for you guys and gals! Smile
*crosses fingers* *sweat beeds falling from forehead* *laughs* Smile

Anyway, let me know what you think. If enough people can get it to successfully work and like it, I will post the Mod in the Resource Center.

Carol, your assistance in reviewing this script is greatly appreciated. I appreciate your feedback and critical analysis of the codes I write. So, don't be afraid to be as honest and blunt as possible.

Warning Warning Warning

When you are testing this script, make sure that you make a copy of your .db file and use that for testing. You can test it with only a few records that have a common email address that you have access to in a test .db file. It is unwise to use your live database file when testing this script. (When using a test .db file, make sure that you change its permissions to 666 (rw-rw-rw-).)

If you do not use a dummy test database file for this script, you will risk the chance of sending out messages to all your database users, which may or may not be appreciated.

Thanks in advance.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited October 06, 1999).]

[This message has been edited by Eliot (edited October 06, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot,

I'm thinking I'm real close on this, :-).

1. I've uploaded http://www.flash.net/~murgnam/mailer_cgi.txt for your review.

2. I was a little confused bye the "Execute this file via your web browser", but tried it at http://www.flash.net/cgi-bin/cgiwrap/murgnam/Directory/mailer.cgi, but get ...

No Email Address or User Name defined in /home/m/u/murgnam/www/cgi-bin/Directory/default.db!
Messages NOT sent!

3. I "think" I'm using sendmail -v- SMTP so I commented out the SMTP part, but the sendmail should be on target.

4. I'm working all this at a dummy site @ http://www.flash.net/cgi-bin/cgiwrap/murgnam/Directory/db.pl, where I've got three records set up to three of my own 7 email addresses.

So ... am I close?

Thanks in advance.

JR
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Yes, you are close...The error message means that you have either not properly defined the email field in your database (hopefully you are using a dummy copy of your database). You do not need to have a separate db.pl to make this work.

With regards to "Executing it via your browser...", all that means typing the location of your mailer.cgi file in the Location/Address blank in your browser and hitting return.

Wink

I do not see any problems with the way you have configured the script. The only thing I would suggest is that you make sure that the $mailfield is the field number of your Email field in your default.cfg file.

Again, the error message means that the script is "working", but there are no emails being listed. What you should see in your web browser is the following:

Content-type: text/html
one@mydomain.com
two@mydomain.com
three@mydomain.com

This means that the email addresses have been successfully pulled from the database and messages should be sent out.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot,
Got it working. Appears all I had to change was the modifiedfield from 1 to 23 -- the earliest date I added a record to my dummy database, and now it works, :-)
But with that comes questions
1. As stated above, I used my own personal email addresses in this dummy database, so as to not bother other folks with my tests, e.g., name@flash.net, but the output came to name@caligula.flash.net. Where'd the caligula come from?
2. The domain referrers. Am I correct in using my servers' www.flash.net, or does that mean it'll only deliver to flash.net mail recipients?
3. I'm to assume whenever I (admin only?) want to send a mass email to my alumni, that I'll have to edit the Subject/Body of the mailer.cgi each time b4 I send?
4. In closing, especially with the priv mail mod, this is ideal for me to get info to my alumni. My last question is shouldn't this be admin only? or is it and I don't really realize it, :-0.

Thank you.

JR
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
joebagodonuts,

1. The email is sent to the email addresses in the database. If the dummy email addresses you set-up are name@caligula.flash.net. Also, your mail server may be set up to send emails to this address.

2. Domain referrers is only to protect the script from being used on another server in case someone got a hold of your mailer.cgi codes.

3) Yes...I am working on a web based email form that will allow you to change the message rather than manually editing the mailer.cgi file. But I wanted to wait to see if the basic mechanics of this script worked before adding stuff to it. However, with the web form, it will defeat the purpose of automating this script. What I could do is have the $subject field be called from a text file, which would allow you to upload a regular text file with a message and still maintain the automated process of the script.

4) If you put this script in a password protected directory, then YES, it will be admin only access. Smile

Regards,


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
COOL, COOL, COOL. Thx.

One more comment tho'. I like to send HTML emails, for those OE/Outlook users and/or other browsers that can accept Stationery Emails. As were working thru a browser, can it work in HTML as well as Plain Text? Know that's asking a lot, but a question nonetheless.

JR
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Hmm....I suppose that would work. Why don't you test it out for yourself, like the following:

Code:
$notify_body_text = '
<b>Hello My Alumni Friends</b>
<p>
<a href="http://www.mydomain.com">Click here</a> to view our new homepage.';

I don't know...try it out and see if it works.

Wink

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot:

I am in the process of setting up this script. I got the info about how to set up Cron jobs from your documentation in the script. I have a generic question.

Can you use "localhost" for the SMTP server? I have configured some other Perl scripts out there for a few customers on Unix that send out emails and the scripts did not have sendmail as the coding for the program, they used SMTP. However, if I used localhost as the SMTP server, the code worked and emails were sent.

If this is the case and it works, can't anyone just use localhost if they do not know the SMTP server for any of the email mods in the Gossamer Threads support forums? Please explain so I hopefully don't get my self in trouble in the future or misguide anyone here. Thanks!
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
You need to specify a SMTP Server...you cannot use localhost. Use something like:

Code:
mydomain.com

The script only functions if a particular SMTP server is dennoted, and it works with Sockets. The Mailer.pm allows the program to connect to a particular SMTP server. It has to be explicitly specified in this script in order to work.

Hope this makes sense.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot,

IRT my comments about Stationery. If you've got an IE browser click on http://www.flash.net/~murgnam/grad1a.html to get a visual of what I'm talking about (Netscape ain't it).

Specifically I want the email background (stationery) to be rich text/HTML -v- plain text. "If" that were possible, I'd want the script to give me the option to send plain text or HTML.

...or I could post the question to one of the stationery NG's, :-0.

JR
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Sorry...don't use MIE...

Wink

So, I don't see what you want.

A word of advice, you should not program something that does not allow 40% of the Internet Community (Netscape Users) to participate.

Did you even try the HTML example I gave? If that works, then all you have to do is put in flags in the configuration area, like the following:

Code:
$html = 1;
$text = 0;

Then in the script add the following codes in the Configuration Section.

Code:
$html_body_text = 'INSERT HMTL CODES';

Then in the mailer routine, edit the following codes:

Code:
if ($smtp) {
foreach $email (@emails) {
my $mailer = new Mailer ( { smtp => '$smtpserver' } )
or die "Can't init mailer: $Mailer::error";
$mailer->send ( {
to => $email,
from => $admin_mail,
subject => "$subject",
msg => $notify_body_text
} )
or die "Can't send mail: $Mailer::error";
}
}

TO THE FOLLOWING:

Code:
if ($smtp) {
if ($html) {
foreach $email (@emails) {
my $mailer = new Mailer ( { smtp => '$smtpserver' } )
or die "Can't init mailer: $Mailer::error";
$mailer->send ( {
to => $email,
from => $admin_mail,
subject => "$subject",
msg => $html_body_text } )
or die "Can't send mail: $Mailer::error";
}
}
if {$text) {
foreach $email (@emails) {
my $mailer = new Mailer ( { smtp => '$smtpserver' } )
or die "Can't init mailer: $Mailer::error";
$mailer->send ( {
to => $email,
from => $admin_mail,
subject => "$subject",
msg => $notify_body_text
} )
or die "Can't send mail: $Mailer::error";
}
}
}

Then follow this type of coding in the sendmail codes.

I don't know if this will work. Just thinking out loud. If it works...great, if not, let's talk some more and hopefully WE can come up with a solution that does work.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited October 26, 1999).]

[This message has been edited by Eliot (edited October 26, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Agreed and I apologize for not even trying yr earlier example. That said pre-DBMan I had my alumni's email addressees separated by plain text and html, e.g., my email's would be formatted for the appropriate group ... which leads me to this thread.

After trying yr example, the output doesn't give me the html/active link, simply the <b>Hello My Alumni Friends</b><p><a href="http://www.flash.net/~murgnam/80s1.htm">Click here</a> to view our new homepage.

Notwithstanding, I went ahead and incorporated the mailer.cgi with the HTML to a piece of stationery, then tried to configure the mailer anyway, but get the folg syntax in my mailer.cgi ...

syntax error at D:\HTML Files\DBMan\Directory/mailer.cgi line 412, near "if {"
"my" variable $Mailer::error can't be in a package at D:\HTML Files\DBMan\Direct
ory/mailer.cgi line 415.

My latest and greatest mailer.cgi is @ http://www.flash.net/~murgnam/mailer_cgi.txt. I don't want to waste yr time with all this html/stationery stuff, but if it's workable, then let's try it, :-)

JR


Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
I am really unsure what you are trying to do. I think that you want to mail out your message in HTML rather than plain text, right?

The problem with what you have in HTML codes is that you have style sheet codes, which cannot be placed between the ' and ';.

I would also take out the mailer codes I gave you before and go with the regular mailer routine I had in place for this script. Also, take out the style sheet codes.

See if that works.

Regards,



------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
It's Working, Thanks! Smile

I feel like a dummy though! I was testing something when I commented out both mailprog routines. My fault, I should have rechecked!

Secondly, the 500 server errors were because I forgot to put the \@ in my email address. Fixed it and boom!!!!!! This actually happened to me on another perl script and I should have remembered. Goes to show to all out there, read the documentation!!

Finally, now I can work on the Cron event. Here is what I have for the .sh file:

Code:
# Send Reminder Email to a user requesting them to make sure they have updated thier records and then log the actions
/home/web/guide/yorkphiladelphia/jobtrack/mailer.cgi > /home/web/guide/yorkphiladelphia/jobtrack/remindlog.txt

Then in my mailer txt file for the Cron event I have as follows:

Code:
# Send reminder email on day 1 and day 15 of every month at 7:00 a.m.
0 7,1,15, * * /home/web/guide/yorkphiladelphia/jobtrack/mailer.sh

I came up with these by following the tutorial in the thread www.gossamer-threads.com/scripts/resources/Detailed/244.html .

Does it all look kosher, Eliot? If it does, I am a happy camper Smile

Also, if this is correct, it will be a guide for others out there trying to implement your wonderful script (since there aren't too many examples of a Cron event in the forum). Any other tricks you can mention, please feel free to do so!

Thanks again. Your services are very much appreciated!



[This message has been edited by BrianYork (edited October 27, 1999).]

[This message has been edited by BrianYork (edited October 27, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot:

If you have a chance, can you please take a look at my files for the mass mailer?

I am configuring the sendmail option and keep getting the dreaded 500 server error. Here is what I have done.

1) I setup the configuration section of my mailer.cgi and uploaded it in ascii mode to my dbman directory. I set the permissions to 755. Please view the file at http://www.yorkphiladelphia.com/jobtrack/mailer_cgi.txt .

2) I downloaded the links2 zip file and got a hold of Alex's Mailer.pm. I uploaded it to my dbman directory in ascii mode. I did not know what the permissions were to be for this file, so I set them to 777.

3) I made my remindlog.txt file and uploaded it in ascii mode. I also set this to 777.

Now, at this point I am only trying to run mailer.cgi from the web browser. So I type http://www.yorkphiladelphia.com/jobtrack/mailer.cgi . All I get is the 500 server error and I cannot figure out why. I know this is usually an issue caused by misconfiguration or permission errors, but I am blind to any that exist.

As a note, I can run perl scripts from any directory on this server as long as I rename the extension from .pl to.cgi.

Any ideas? I tested Joebagodonuts setup via the browser and I see how this thing is supposed to work. Once I get it working, then I will tackle the Cron events.
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
The reason is that you have commented out ALL the sendmail configurations. TAKE out the # characters in front of the following variables:

$sendmail

and

$mailprog

You need to rem out EITHER SMTP configurations OR SENDMAIL configurations, BUT NOT both.

Also, you need to have a \ before the @ sign in the admin_mail variables (which I have shown in the example).

After you have fixed these mistakes and you still can't get it to work, check the following:

1) Perl path in the first line of the script.
2) Upload file as ASCII to your web server.
3) Change permission of file to 755 (rwx-r-xr-x).

If it still doesn't work, then post the EXACT error messages you receive.

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited October 27, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
The shell file (.sh) looks fine. But there is a problem with your crontab set-up. You have set it up to run at 7:00 a.m., 1:00 a.m., and 3:00 p.m. EVERYDAY.

You should set up your crontab in the following manner:

Code:
# Send reminder email on day 1 and day 15 of every month at 7:00 a.m.
0 1 * * 1,7,15 /home/web/guide/yorkphiladelphia/jobtrack/mailer.sh

This will send out the mail at 1:00 a.m. on the 1st, 7th, and 15th of the month.

For those NT users out there, USE AT SCHEDULER or another SCHEDULING PROGRAM. DO NOT ATTEMPT TO FOLLOW THESE INSTRUCTIONS.

Smile

Hope this helps.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited October 27, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot,

Think I'm ready to transfer this mod from the dummy site to the real site. But b4 I do, I'd like to make sure I'm clear on a couple things ...

1. After I edit the subject/body and send to my alumni, I should then chmod to 444, so as any others who may know the Address can't execute ... right?

2. The reminddays field. Does that "automatically" send another email after the days specified ... or just flag me that it's time to send something else? I'd rather it not be a monthly newsletter thing, just when I "need" to pass on info. But then again, I don't use (or know how) that Cron thing works anyway, so the reminddays field is prob a mute point anyway?

3. My biggest concern is I don't want/nor is it my desire for this mod to appear as spam to my alumni. Just want to be able to pass on info to the group on an as needed basis only.

Over

JR

NOTE: I think it's prob best to leave this mod as plain text ... least in the short term ... so I'm going to table my whole HTML/Stationery idea for awhile.
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
joebagodonuts,

1) You ONLY change the permission to 444 when you want to "turn off" the script from being used. If you are going to use this script with Cron for UNIX or AT Scheduler, you should maintain the permission of 755 for the script.

2) I only use the remind field because I am using it to send out messages to NT Users in our Computer Network to let them know that their password has expired (since NT servers do not communicate very well with Windows 95 users...). So, for most people the remind field is a mute point.

3) What you could do is set this script to be a monthly newsletter...All you have to do is take out the remind field and then execute this script once a month using Cron for UNIX or NT Scheduler.

About the HTML format, I am going to be working on a HTML web form based form that will people to choose to send the message as text or HTML. I don't gaurantee I will have this script updated to allow this in the near future...I've take a new job in Boulder, CO and I will be busy moving and starting my job in the next few months. But when things settle down...I will re-visit this script and hopefully have a new release by the end of January...but NO gaurantees....

Anyone is welcome to add to this script!

Smile

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Delete the logging routine and also the reference to the logging routine:

Code:
&logging;

and see if that solves the problem.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
This is what happens and the server is keep returning the 500 error, and I have everything ok.
you can check the script on: huntmexico.com/files/mailer.txt

Checking //usr/local/etc/httpd/cgi-bin/proveedores/mailer.cgi for common errors:

Existance check...
File Exists.
Checking for zero size...
File size is OK.
Checking permissions...
File is executable.
Checking for ASCII format...
File is an ascii file.

Checking Syntax...
Syntax is OK!

Sincerely
karla
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Well, make sure that the file is set to 755 (rwxr-xr-x). While your perl test shows that it is executable, you still may not have set the permission of the file correctly. Change it to 755.

Regards.

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited December 06, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
You did not follow the instructions of how to configure the sendmail versus SMTP options!

You did not configure the SMTP configurations correctly!

They should be like the following:

Code:
$smtp = 1;
$mailer_path = "/usr/local/etc/httpd/cgi-bin";
require $mailer_path . "/Mailer.pm";
$smtpserver = "huntmexico.com";

Quote:
#############################################################
# MAIL PROGRAM CONFIGURATIONS
#
#This sub-section is for configuring your sendmail or SMTP
# Configurations. If you are using SMTP, then you must set
# the following variables:
# $smtp = 1;
# require $mailer_path . "/Mailer.pm";
# $mailer_path = "";
# $smtpserver = "mydomain.com";
#
# UNIX Example for $mailer_path (NOTE: No Trailing Slash):
# $mailer_path = "/mnt/guide/web/myaccount/cgi-bin/sendmail";
#
# NT Example for $mailer_path (NOTE: No Trailing Slash):
# $mailer_path = "C:/InetPub/wwwroot/myaccount/cgi-bin/sendmail";
#
# You will also need to download the Mailer.pm module if you
# do not have it on your server. This module can be downloaded
# at perl.com, cpan.com, or gossamer-threads.com.
#
# If you are using Sendmail, then you must set the following
# variables:
# $sendmail = 1;
# $mailprog = "";
#
# UNIX Example for $mailerprog:
# $mailer_path = "|/usr/sbin/sendmail -t -eoq";
#
# NT Example for $mailerprog:
# $mailer_path = "|C:/Winnt/system32/blat.exe -t -eoq";
#
# NOTE: You must set either $sendmail or $smtp to 1 depending
# on which mail program you are using. The other variable you
# are not using, make sure that you set it to 0. Also make sure
# that you rem out (comment out) the other variables you are
# not using by adding a # character to the front of the $ sign.
#############################################################

Also, again, please check to make sure that your perl path is correct.

That should help.

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------




[This message has been edited by Eliot (edited December 06, 1999).]
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
Eliot, the mailer.cgi is not working it returns an 500 error and in the perl debugger says that the socket.pm cant be found.
Is there something I could do?
Thanks
Karla
Quote Reply
Re: Stand Alone Mass Email Script Mod: Beta Version In reply to
If you are using SMTP, you need to have the Mailer.pm file from LINKS installed on your web account.

Wink

This is clearly stated in the instructions section of the script. Read it more carefully.

Wink

Regards,

------------------
Eliot Lee
Anthro TECH,L.L.C
www.anthrotech.com
----------------------


> >