Author Topic: $subject_field not replacing email Subject. Same for From.  (Read 2257 times)

0 Members and 1 Guest are viewing this topic.

Offline Air_Cooled_Nut

  • Newbie
  • *
  • Posts: 4
$subject_field not replacing email Subject. Same for From.
« on: July 17, 2007, 08:50:05 PM »
The instructions aren't clear about:
  my $subject_field = "subject";
  my $from_field_name = 'fieldname';

I'm an experienced VBA programmer and above average with HTML.  For the life of me I cannot get the email Subject field nor the email From field to change to the values I have in my forms  tags! 

Plus it *seems* like there's an inconsistency with single and double quotes in the Perl script and your examples (as copied above).  But maybe there's not since I'm not a Perl programmer.

Here's the snipets from my .pl script:
Code: [Select]
my $from                     = 'type3@icbm.org';
my $subject                  = 'Generic subject line.';
my $subject_field            = "subject";
my $from_field_name          = 'fromfield';
and here's the snipets from my HTML page:
Code: [Select]
<INPUT TYPE="hidden" NAME="subject" VALUE="Gearing Analyzer request.">
...
<INPUT NAME="fromfield" TYPE="text" SIZE=50>
As far as I can tell, my INPUT NAME matches the variables in my Perl script and the form fields should be replacing the email defaults.

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: $subject_field not replacing email Subject. Same for From.
« Reply #1 on: July 18, 2007, 05:48:40 AM »
Air,

Change your script code from:

Code: [Select]
my $from                     = 'type3@icbm.org';
my $subject                  = 'Generic subject line.';
my $subject_field            = "subject";
my $from_field_name          = 'fromfield';

To:
Code: [Select]
my $from                     = '';
my $subject                  = '';
my $subject_field            = "subject";
my $from_field_name          = 'fromfield';

If you want the form to write the subject and the from field you need to clear out the my from and my subject from the script.  Of course I don't use the form 2 email script much, but that should do it for you.

Jason
Founder of www.slipdex.com

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: $subject_field not replacing email Subject. Same for From.
« Reply #2 on: July 18, 2007, 12:34:54 PM »
Don't worry about the single and double quotes, they are ok as it is.  (and I'm an experienced Perl programmer  ;D)

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: $subject_field not replacing email Subject. Same for From.
« Reply #3 on: July 18, 2007, 12:40:11 PM »
Still, it should work even if you have $subject and $from filled out.  Is the rest of the form data in the mail?  If not you might want to check whether your perl version is 5.006 or higher.

Offline Air_Cooled_Nut

  • Newbie
  • *
  • Posts: 4
Re: $subject_field not replacing email Subject. Same for From.
« Reply #4 on: July 18, 2007, 12:52:21 PM »
Nope, not working :(

The email that gets sent:
POSTDATA: subject=Gearing Analyzer request.
fromfield=test@test.com

The email From: and Subject: header fields do not get populated, they are just blank now ???  From this I can see that the INPUTs are being processed.  They're just not being placed into the email the way I'd like.  I would eventually like to use this CGI script for multiple forms so it would be nice to have one .pl script with my HTML pages making the necessary changes.  I understand that if this doesn't work then I can resort to using a different .pl script for each different email form.

My web server stats:
Operating system Linux
Kernel version 2.4.21-47.0.1.ELsmp
Machine Type i686
Apache version 1.3.37 (Unix)
PERL version 5.8.0
Path to PERL /usr/bin/perl
Path to sendmail /usr/sbin/sendmail
Everything appears to be meeting the minimum requirements.

Offline Air_Cooled_Nut

  • Newbie
  • *
  • Posts: 4
Re: $subject_field not replacing email Subject. Same for From.
« Reply #5 on: July 18, 2007, 12:55:46 PM »
Here's the calling HTML:
Code: [Select]
<form action="/cgi-bin/foo.pl" method="post" enctype="text/plain"><INPUT TYPE="hidden" NAME="subject" VALUE="Gearing Analyzer request.">
<table>
<tr><td><p>Please enter your email address: <INPUT NAME="fromfield" TYPE="text" SIZE=50></td></tr>
<tr><td align=center><INPUT TYPE="submit" value="Send request" style="color: #ffffff; background-color: #000000"></td></tr>
</table>
</FORM>
As per the recommendation from the web site, I changed the filename of the .pl script (and foo.pl is not it).  I know it is successfully being called, mostly because any mistakes will bring up an error :)
« Last Edit: July 18, 2007, 12:57:26 PM by Air_Cooled_Nut »

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: $subject_field not replacing email Subject. Same for From.
« Reply #6 on: July 18, 2007, 12:56:14 PM »
Very odd  ???.

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: $subject_field not replacing email Subject. Same for From.
« Reply #7 on: July 18, 2007, 12:57:16 PM »
Also, try taking out the enctype (enctype="text/plain")

I am a bit at a loss here as it seems as if your script is not receiving the inputs from the HTML form at all...
« Last Edit: July 18, 2007, 01:00:10 PM by EZ »

Offline Air_Cooled_Nut

  • Newbie
  • *
  • Posts: 4
Re: $subject_field not replacing email Subject. Same for From.
« Reply #8 on: July 18, 2007, 12:59:51 PM »
Also, try taking out the enctype (enctype="text/plain")
That fixed it!

Thank you :D