Home: Perl Programming Help: Intermediate:
Might be Basic questions : sendmail and connecting to mySQL via DBI



Merlin
journeyman

Sep 24, 2000, 12:15 PM


Views: 940
Might be Basic questions : sendmail and connecting to mySQL via DBI

Ok, two things :
1-) Trying to do basic sendmail but the server is ALWAYS giving me an internal error. Server is Linux running Apache 1.3. The mini-script :
#!/usr/bin/perl
open (MAIL, "|/usr/sbin/sendmail -t") | | &erreur;
print MAIL "To: me\@mymail.com\nFrom: someone\@theirmail.com\n";
print MAIL "Subject:test!\n";
print MAIL "Message\n";
close (MAIL);

print "Content-type:text/html\n\n";
print "ok!";

sub erreur {
print "Content-type:text/html\n\n";
print "Erreur Sendmail!\n";
}
Nothing works with this... I tried changing the filehandle, with or without the pipe, removing all print MAIL statements, etc. Any help or comments about syntax highly appreciated.
2-) I'm running a web site that's on secure and non-secure servers. Both Linux with Apache, running mySQL 3.22.32, CGI, DBI, DBD::mysql. The trouble is that on one, my command to connect to my database works fine but the same one on the secure server gives me an error. The connection statement :
use CGI; use DBI;
$dbh = DBI->connect('dbi:mysql:boulangerie:amidala.iweb-hosting.com','username','password');
I know the problem's there since the script runs fine on the secure server if I just remove the connect statement (no internal server error). Any help? Thanks in advance... I'm a bit rushed here since the contract I'm doing is a bit overdue... Wink


Kanji
User

Sep 24, 2000, 4:19 PM


Views: 940
Re: Might be Basic questions : sendmail and connecting to mySQL via DBI

Check your server error logs. They'll tell you what's wrong or at least give you clues.

If you don't have access to your logs, place ...

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

use CGI::Carp 'fatalsToBrowser';</pre><HR></BLOCKQUOTE>

... near the top of your script so that errors go to the browser instead of that pesky -- and unhelpful -- SERVER ERROR.


Kanji
User

Sep 24, 2000, 4:22 PM


Views: 940
Re: Might be Basic questions : sendmail and connecting to mySQL via DBI

Oh, on your mail issue ... you need TWO newlines between header and message, otherwise they're all assumed to be headers.


Merlin
journeyman

Sep 24, 2000, 5:41 PM


Views: 940
Re: Might be Basic questions : sendmail and connecting to mySQL via DBI

Thanks so much, I just solved the part about sendmail. And the tip for more descriptive error messages will be extremely helpful. I was just saying to my provider how lame the error messages where but this will definitely be a big plus. Thanks again! Smile


Merlin
journeyman

Sep 25, 2000, 4:38 AM


Views: 940
Re: Might be Basic questions : sendmail and connecting to mySQL via DBI

mmmmhhh... I tried your use CGI::Carp 'fatalsToBrowser'; in a script of mine and I keep getting the same ol' internal error instead of more details. Know what this could be about? Thanks!


Merlin
journeyman

Sep 26, 2000, 6:32 AM


Views: 940
Re: Might be Basic questions : sendmail and connecting to mySQL via DBI

The CGI function now works! I'm REALLY living in the twilight zone now... (working,not working,working,not working...) Thanks!