Click to See Complete Forum and Search --> : subject field not working in html emails


druss
07-30-2003, 04:38 AM
i have a script that bulk sends the html document to all the subscribers with a feild that i enter. the thing is that when i send it the subject field is screwed after the first email.

for example, i would enter "This is my subject" in a form field. after the first email the rest end up with a subject "This" the rest gets cut out


This is the script that is sending the email

-------------------
open (MAIL, "| $mailprog >/dev/null");
print MAIL <<END;
To: $slot
From: $email
Subject: $name sends you a funnny picture - Make Me Laugh
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="$boundary"

--$boundary
Content-Type: text/html
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
END

open(code,"$templates/friend_email_pic.htm");
@code = <code>;
close(code);

s/\$name/$name/g for @code;
s/\$note/@note/g for @code;
s/\$pic/$pic/g for @code;

print MAIL "@code";

close(MAIL);
--------------------------------


Its quite wierd. as i do rerun the script after sending each email but the subject field is the only one stuffing up??

Any help is greatly appreciated

Thanks
Gozza

goofball
07-30-2003, 10:08 AM
From your code, I can't tell what data structure your subject goes into from the form field .... I assume you're using some kind of loop that sets the $name, $slot, etc. vars each time through before sending the email. Whatever variable you have containing that string is being re-set between the first and second iteration of the loop.

Maybe this is how:?
----------------
If the string "This is my subject" ever becomes part of an array, the string could be splitting on the whitespace. Then if you take a string variable back out of that array, you could easily get the first element - "This".
----------------

In my experience, whenever you're doing things inside of a loop and have a problem like a variable getting re-set, it helps to go back and re-trace the variable in question at each statement of the script. Make sure you aren't inadvertantly altering data by using temp. vars in the wrong places (misusing variables' scope).
If you have access to your server error_log it helps. Put a "warn" statement after any code you think might be causing problems.

warn "$subject $!";

make sure NOT to put a newline (\n) on the end of the warn statement, and it will tell you the line number of the script where the error occurred automatically. :)

happy bug hunting