[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Emial cgi messed up

Posted on 2002-04-03
6
Medium Priority
?
207 Views
Last Modified: 2013-12-25
I got a prob with this script. It attaches the message to the end of the subject line. It used to work but I edited some stuff and must have messed it up somehow. I wrote this but my knowledge of perl/cgi came out a book and this is one of 3 scripts I've ever written.


#!/usr/local/bin/perl

use CGI ':standard';

sub send_mail {
my($to, $return, $subject, @body)=@_;
open MAIL, "|/usr/vde/bin/sendmail -t";
print MAIL "To: $to\n";
print MAIL "Reply-to: $return\n";
print MAIL "From: $return\n";
print MAIL "Subject: $subject\n - (IP# $theirIPAddress )";
foreach(@body) {
print MAIL "$_\n";
}
close(MAIL);
}
$theirIPAddress=$ENV{'REMOTE_ADDR'};

print header, start_html;




@body=param('body');
if(param('target'))
{

send_mail(param('target'), param('return'), param('subject'), @body);
}
0
Comment
Question by:Bob Stone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 800 total points
ID: 6916875
stone5150,

"..It attaches the message to the end of the subject line. .."

REPLACE..

print MAIL "Subject: $subject\n - (IP# $theirIPAddress )";

WITH...

print MAIL "Subject: $subject\n - (IP# $theirIPAddress )\n";

Let me know how it goes.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6916878
I dunno, tho' I made better comment not long ago (bad memory).

As I understand it, today, this is rfc issue, not perl. The subject being variable length field requiring special terminator.

I think by 'special', in olden times it was xMit (KB) of two nulls by hitting return twice. So in C or Perl, I'd try first

\n\n

since it is quick, then go look it up (rfc)(or Perl script support site) to see if it was supposed to be real null character or perhaps only a single period on line followed by <cr>

I think it is suggested at about 68 char limit for subject, and 'should be' one single visible line, that can be parsed/scrolled to next/multi-line. With another suggestion for real max

If you don't get far but do get impatient, let me know and I'll check/see if I preserved some of those bookmarks.
0
 
LVL 24

Expert Comment

by:SunBow
ID: 6916883
maneshr,
I haven't the time here. If you do, I think there were references in EE for some threads that were discussing legal characters for recipient ("to: ___").
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
LVL 24

Expert Comment

by:SunBow
ID: 6916889
<ugh> forgot to leave.
Check out example within last visible open q: on the Topic page:
http://www.experts-exchange.com/cgi/Q.20254607.html

- a couple examples of the syntax for double <CR>'s therein... my ref:

\n\n

terminator (multiline)
0
 
LVL 9

Author Comment

by:Bob Stone
ID: 6918204
I replaced;

print MAIL "Subject: $subject\n - (IP# $theirIPAddress )";

with this;

print MAIL "Subject: $subject - (IP# $theirIPAddress )\n";

and it worked perfectly. Just forgot to close the line or whatever you call it.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 6918458
stone5150,

"..and it worked perfectly...."

Excellent!!!

"..Just forgot to close the line or whatever you call it. .."

Glad to know you got the solution you were looking for.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question