|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
I'm trying to write a script to read e-mail addresses out of a text file and send each a standard messgage (not for spamming btw).
Trouble is, only the last e-mail is sent correctly. In all the previous e-mails the "from" and "subject" lines are just put as part of the body of the e-mail not in the header. I'd be really greatful if anyone could help me out with this puzzler... The relevent bits of the script are below: Example bits of script: open (MAILIT, "<../../../logs/test/mail.txt"); @mailtolist = <MAILIT>; close (MAILIT); (Whats contained in mail.txt) dedicate@zetnet.co.uk trev@dedicate.co.uk dedicate2@zetnet.co.uk # The print bit of the script foreach $message(@mailtolist) { if ($message ne "") { if ($message =~ /@/) { open (MAIL, "|/usr/sbin/sendmail -t") | | &errormail; print MAIL "To:$messagenFrom:$fromn"; print MAIL "Subject: New website!n"; print MAIL "Testing mailing script 3n"; close (MAIL); } } } Other points: If I use the following to put data info the array manually it works fine... $mailtolist[0] = "dedicate@zetnet.co.uk"; $mailtolist[1] = "trev@dedicate.co.uk"; $mailtolist[2] = "dedicate2@zetnet.co.uk"; Cheers Trev |
|
#2
|
||||
|
||||
|
I'm not sure will this help but try escaping @ character if ($message =~ /@/) {'
and this line should be 'print MAIL "Subject: New website!nn";' |
|
#3
|
|||
|
|||
|
>> I'm not sure will this help but try escaping @ character if ($message =~ /@/) {'
and this line should be 'print MAIL "Subject: New website!nn";' << Finally discovered what putting in is called... It seems happy with the escaping of the @ but the ' marks around the print line I just get an internal server error. Cheers for the suggestion! Trev |
|
#4
|
|||
|
|||
|
youre printing an extra newline after the to address. Do this:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> foreach $message(@mailtolist) { chomp $message; if ($message ne "") { if ($message =~ /@/) { ... [/code] also you should print 2 newlines after subject. |
|
#5
|
|||
|
|||
|
Cheers, that did it!
I actually tried earlier putting the Subject: and From: above the To: which seemed to get around it, but I'm not sure all mail programs would thank me for that. Always best to know the right way of doing things... Cheers Trev |
|
#6
|
|||
|
|||
|
sendmail
hi
can u tell me where and how i can get this thing called sendmail...so that the mail can be sent....i need it badly.... rite now i dont even know what it is...and am not sure where i am must store it. thanks kats I actually tried earlier putting the Subject: and From: above the To: which seemed to get around it, but I'm not sure all mail programs would thank me for that. Always best to know the right way of doing things... Cheers Trev [/B][/QUOTE] |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Strange sendmail problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|