Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old December 16th, 2000, 06:03 PM
TrevH TrevH is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 TrevH User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old December 16th, 2000, 07:41 PM
Pepe''s Avatar
Pepe' Pepe' is offline
the one
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Location: .hr
Posts: 99 Pepe' User rank is Sergeant (500 - 2000 Reputation Level)Pepe' User rank is Sergeant (500 - 2000 Reputation Level)Pepe' User rank is Sergeant (500 - 2000 Reputation Level)Pepe' User rank is Sergeant (500 - 2000 Reputation Level)Pepe' User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 20 h 56 m 52 sec
Reputation Power: 16
I'm not sure will this help but try escaping @ character if ($message =~ /@/) {'
and this line should be 'print MAIL "Subject: New website!nn";'

Reply With Quote
  #3  
Old December 17th, 2000, 08:37 AM
TrevH TrevH is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 TrevH User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> 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

Reply With Quote
  #4  
Old December 17th, 2000, 11:35 AM
Dingle Dingle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2000
Posts: 452 Dingle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 12 sec
Reputation Power: 8
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.

Reply With Quote
  #5  
Old December 17th, 2000, 03:44 PM
TrevH TrevH is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 TrevH User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #6  
Old February 13th, 2001, 09:11 AM
cancerkats cancerkats is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2001
Posts: 3 cancerkats User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Strange sendmail problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway