sendmail

K

kd

Hi all,

I am working on a program which uses sendmail.I found that the sendmail
directory was located at /usr/sbin/sendmail. I try to execute the
following piece of code. But the program shows any errors nor executing
it properly.Could you please let me know what the problem could
be.Thanks in advance.

- Karthik
===================================================
#!/usr/bin/perl/
use strict;
use diagnostics;
use warnings;
system('clear');

open(SENDMAIL,"|/usr/sbin/sendmail -oi -t -odq")or die "Can't fork for
sendmail: $!\n";
print SENDMAIL <<"EOF";
From: Karthik <karthik\@kmail.com>
To: Karthik <karthik\@kmail.com>
Subject: A relevant subject line
Hey Wats up !!
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely";
===================================================
 
A

A. Sinan Unur

I am working on a program which uses sendmail.I found that the
sendmail directory was located at /usr/sbin/sendmail.

Is that the directory, or the full path to the binary?
I try to execute the following piece of code. But the program shows
any errors nor executing it properly.

Well, what are the errors it shows?
#!/usr/bin/perl/

This is incorrect.

#!/usr/bin/perl

....
print SENDMAIL <<"EOF";
From: Karthik <karthik\@kmail.com>
To: Karthik <karthik\@kmail.com>
Subject: A relevant subject line
Hey Wats up !!
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely";

Don't you need to signal the end of the message to sendmail by sending a
..CRLF to sendmail?

Sinan
 
S

Shane

Hi all,

I am working on a program which uses sendmail.I found that the sendmail
directory was located at /usr/sbin/sendmail. I try to execute the
following piece of code. But the program shows any errors nor executing it
properly.Could you please let me know what the problem could be.Thanks in
advance.

- Karthik
=================================================== #!/usr/bin/perl/
use strict;
use diagnostics;
use warnings;
system('clear');

open(SENDMAIL,"|/usr/sbin/sendmail -oi -t -odq")or die "Can't fork for
sendmail: $!\n";
print SENDMAIL <<"EOF";
From: Karthik <karthik\@kmail.com>
To: Karthik <karthik\@kmail.com>
Subject: A relevant subject line

you need a blank line between your headers ^^ above and your body below
 
A

Anno Siegel

A. Sinan Unur said:
[...]
print SENDMAIL <<"EOF";
From: Karthik <karthik\@kmail.com>
To: Karthik <karthik\@kmail.com>
Subject: A relevant subject line
Hey Wats up !!
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely";

Don't you need to signal the end of the message to sendmail by sending a
.CRLF to sendmail?

No, closing its input is enough. You need dot-on-a-line to make sendmail
quit *before* it reaches eof.

Anno
 
A

A. Sinan Unur

(e-mail address removed)-berlin.de (Anno Siegel) wrote in
A. Sinan Unur said:
[...]
print SENDMAIL <<"EOF";
From: Karthik <karthik\@kmail.com>
To: Karthik <karthik\@kmail.com>
Subject: A relevant subject line
Hey Wats up !!
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely";

Don't you need to signal the end of the message to sendmail by
sending a .CRLF to sendmail?

No, closing its input is enough. You need dot-on-a-line to make
sendmail quit *before* it reaches eof.

I learn something new every day. Thanks.

Sinan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top