Guest Rob Posted January 27, 2003 Report Share Posted January 27, 2003 I would like to create personalized email with names etc that are in a database, if possible even in html. is there an email program capable of such a thing ? rob Quote Link to comment Share on other sites More sharing options...
aru Posted January 27, 2003 Report Share Posted January 27, 2003 you can do it via shell script, coded with bash, python, perl or whatever you like and to the personalized limits that you can imagine... it is quite easy. I use python[1] for that purpose (using the smtplib module) [1] Message for some people on this board: YES!!! *python* instead of bash!!! as I use for this task an old script that I wrote years ago. I learned python before "bash scripting"!!!! :roll: :lol: Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted January 27, 2003 Report Share Posted January 27, 2003 Thanks for your reaction, but as i am a total linuxnewbie with no computereducation (when i finished school the first commodore 64 home pc was launched) i have no idea how to get familiar with this easy topic. may be there are resources for helping me to get started? rob Quote Link to comment Share on other sites More sharing options...
aru Posted January 27, 2003 Report Share Posted January 27, 2003 OK, here is the very easiest way to do it: Let's suppose that you have a file (address_list.txt) which only has data in the format email address / user name, as follows: rms@gnu.org Richard S. Stallman user1@hostname.ext Bill Smith linus@linux.org Linux Torvals ... This could be your *spam* script: #!/bin/sh address_file="address_list.txt" #-- name of the addresses list file. --# SENDER=billgates@microsoft.com #-- Sender of the message --# SUBJECT="SPAM SPAM SPAM" #-- Subject --# while read ADDRESS NAME; do #-- gets the mail address and the user name from thea ddresses list file and mails the message in html encoded mode. --# /usr/sbin/sendmail ${ADDRESS} << MAIL_MESSAGE From: ${SENDER} To: ${ADDRESS} Subject: ${SUBJECT} Mime-Version: 1.0 Content-Type: text/html <html> <body> <p>Dear, ${NAME}:</p> <p>text body here</p> </body> </html> MAIL_MESSAGE done < ${address_file} The message is all that goes between both "MAIL_MESSAGE" strings. It should have the mail headers, a blank line, and the message body (in this case in html) It is just an example, you'll need to fit it to your own needs, for example to merge it with a mysql database output, you can do: #!/bin/sh SENDER=billgates@microsoft.com SUBJECT="SPAM SPAM SPAM" MYSQL_CMD="select email full_name from addresses_list_table" MYSQL_DATABASE="employers_db" echo "${MYSQL_CMD} | mysql ${MYSQL_DATABASE} | while read ADDRESS NAME; do ... same code as in the above example... done HTH Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted January 27, 2003 Report Share Posted January 27, 2003 thanks for reaction. i will try this next weekend, for i expect it to take some time. bye the way, i am not a spammer, just trying to find an easy way to answer the filled in forms of my site. Quote Link to comment Share on other sites More sharing options...
aru Posted January 27, 2003 Report Share Posted January 27, 2003 of course not, I was only joking. I wrote the script with the discussion of Bill Gates spamming thread at offtopic in mind :lol: Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted January 29, 2003 Report Share Posted January 29, 2003 I have looked at the script posted above, it seems very promising to me. There is one question, i understand the script calls sendmail for sending the created emails. I wonder if that is usable to me. I use mandrake 9.0 on a stand alone pc, and use my isp smtp server to send mail. As far as i found out so far, 9.0 uses procmail instead of sendmail. are these programs used anyway when using my isp smtp server, i dont understand much of it. Anyway, most burning question now is will emails be actually send when the script calls sendmail, or do i need to use something else. Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted January 29, 2003 Report Share Posted January 29, 2003 Looking further into this stuff, i come to the conclusion that for keeping control of what i send away i would prefer the messages created by the script delivered somewhere in a local folder, or even better the outbox of an email client. can i instruct the script directly to do so, or do i need sendmail, procmail, or ssmtp to carry out this. Quote Link to comment Share on other sites More sharing options...
aru Posted January 29, 2003 Report Share Posted January 29, 2003 I have looked at the script posted above, it seems very promising to me. There is one question, i understand the script calls sendmail for sending the created emails. I wonder if that is usable to me. I use mandrake 9.0 on a stand alone pc, and use my isp smtp server to send mail. As far as i found out so far, 9.0 uses procmail instead of sendmail. are these programs used anyway when using my isp smtp server, i dont understand much of it. Anyway, most burning question now is will emails be actually send when the script calls sendmail, or do i need to use something else. Disclaimer: I don't understand much of it too ;) But AFAIK, it has nothing related to your isp smtp server as you, as you're using linux, have your own smtp server. I used the sendmail (clone?) provided by postfix (my mail system). But there is a sendmail package. About procmail I have to confess that I don't have experience with it, so maybe others will help you. But anyhow, for what I've seen it the procmail man page, it needs a sendmail installed in order to work (Under files: /usr/sbin/sendmail default send mail program); so you should (would) have a copy (clone?) already installed. In any case, you must (or should) have installed a program that will do the function of /usr/sbin/sendmail. Looking further into this stuff, i come to the conclusion that for keeping control of what i send away i would prefer the messages created by the script delivered somewhere in a local folder, or even better the outbox of an email client. can i instruct the script directly to do so, or do i need sendmail, procmail, or ssmtp to carry out this. I think I don't understand your question, maybe because english is not my language. Could you explain it better? Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted February 1, 2003 Report Share Posted February 1, 2003 what i ment is this? When i see the command "sendmail" in the script i think the emails created bye the script will be sent away immediately.(dont know what happens if there is no open connection to internet). Especially in the beginning i would to see the mails before i send them to potiential customers. That is why i would like the emails produced bye the script to be stored somewhere on my local disc. So my question is do i need to change the sendmail line to be able to see the files before sending them. I dont understand much of how sending email is organized in linux, but as far as i understand sendmail is not needed on stand alone computers. Or, as the post above tells me, i already should have something like that installed with 9.0. If so, what is it, because now i dont even know what to configure left alone how. Bye the way, today i got msacces working with wine, which for me is another victory. Quote Link to comment Share on other sites More sharing options...
aru Posted February 1, 2003 Report Share Posted February 1, 2003 When i see the command "sendmail" in the script i think the emails created bye the script will be sent away immediately.(dont know what happens if there is no open connection to internet). sendmail, postfix, qmail... are MTAs (Mail Transfer Agents) also known as Mail Servers. They take the message and establish the route to the "target" email address. If there is no connection to internet, then the messages are kept till the server can access internet, then it sends the emails. In my example, as I use postfix as my email server, I've used a sendmail (clone?) that comes with postfix. In my script the emails are generated and sent away immediately whether or not the connection is established. Remember that the mail server will take care of the messages till the connection is established, so you dont have to be online to send the emails. Especially in the beginning i would to see the mails before i send them to potiential customers. That is why i would like the emails produced bye the script to be stored somewhere on my local disc. So my question is do i need to change the sendmail line to be able to see the files before sending them. My strategy in that case is to add a bit of code to handle tests, so I sent all my testing messages to myself (user@localhost) thus I can hack the code of the message to feet my needs, and when I'm sure that all works, then I run the script with the real "costumers" addresses. I dont understand much of how sending email is organized in linux, but as far as i understand sendmail is not needed on stand alone computers. Or, as the post above tells me, i already should have something like that installed with 9.0. If so, what is it, because now i dont even know what to configure left alone how. It is NEEDED on stand alone computes. It should be already installed one mail server in your machine, because many system reports are sent by mail to root (ie: cron tasks). So for admin purposes is important to have the ability to send/retrieve mail within your own machine. One thing you can do to know which mailserver do you have installed is: [arusabal@localhost ~]$ rpm -qa | egrep "postfix|qmail|sendmail|exim" HTH Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted February 3, 2003 Report Share Posted February 3, 2003 Found out a little about postfix, thanks to muo document about postfix configuration. I have it working now, though i still have to do some things, for instance i want to be able to view messages in the mail queue. Most important is that postfix reacts on the sendmail command used by email clients, and so i expect it will also react to the sendmail command in the script. I have to get a little more confident with all this, but i am already looking forward to go testing with the script. Quote Link to comment Share on other sites More sharing options...
Guest Rob Posted February 4, 2003 Report Share Posted February 4, 2003 I have got it working, though i had some problems first. As a newbie i had to type the script in an editor, then found out how to call a script to work when you''re in the same directory, and then the fun began. first i had mails where the header was in the message, changed the place of "MAIL_MESSAGE" which did not seem to work. But when i changed <html> etc to <HTML> it all began to work fine. For testing reasons i changed as little as possible, and now it all works fine. Never before have i been more happy to receive an email from bill gates, and i guess i never will be. I think i begin to see a little why linux is more than a windows substitute. There is one strange thing however, as i told before i have set up postfix exactly like described in the muo document http://www.mandrakeuser.org/docs/connect/cmail2.html and added "defer_transport =smtp" to main cf. When i type mail in a root console mail for external recepients is sent away (via smtp server of my isp), but i dont get my cursor (#) back, it changes to & . It has jumped to some mode i know nothing about, and the reaction to the keyboard is not what i expect ( any key prodces something like [[A) I dont know how to change that. But that does not bother me much, i am very happy now. THANK YOU ALL for your great help. Rob. Quote Link to comment Share on other sites More sharing options...
aru Posted February 4, 2003 Report Share Posted February 4, 2003 I have got it working, though i had some problems first. As a newbie i had to type the script in an editor, then found out how to call a script to work when you''re in the same directory, and then the fun began. first i had mails where the header was in the message, changed the place of "MAIL_MESSAGE" which did not seem to work. But when i changed <html> etc to <HTML> it all began to work fine. For testing reasons i changed as little as possible, and now it all works fine. Never before have i been more happy to receive an email from bill gates, and i guess i never will be. I think i begin to see a little why linux is more than a windows substitute. Glad to read that, but in my opinion GNU/Linux never meant to be a windows substitute, It is intended to be an UNIX substitute, which is by far much more ambitious :D There is one strange thing however, as i told before i have set up postfix exactly like described in the muo document http://www.mandrakeuser.org/docs/connect/cmail2.html and added "defer_transport =smtp" to main cf. When i type mail in a root console mail for external recepients is sent away (via smtp server of my isp), but i dont get my cursor (#) back, it changes to & . It has jumped to some mode i know nothing about, and the reaction to the keyboard is not what i expect ( any key prodces something like [[A) I dont know how to change that. When you get the & prompt you ARE inside the mail program; run man mail and you'll see where/what were you doing. mail can behave interactively (which IMHO is the worst way of reading/sending mail I've ever tried), and that's where you were when you got the "&" prompt. ;) But that does not bother me much, i am very happy now. THANK YOU ALL for your great help. Rob. YOU ARE WELLCOME, and have fun!!! :D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.