PDA

View Full Version : Sendmail from perl


pmarg212
01-11-2007, 07:18 AM
Greetings,

I wrote the helloworld.pl script in my /home/mydomain/ directory (Copied below). It is just intended to send a single email. However, when I run it using "perl helloworld.pl" I get the out put: "sendmail: No recipients found, aborting..."

What is the proper way to send an email from a perl script on this server? Thanks for your help!

Paul

___THE SCRIPT____


#!/usr/bin/perl

my $sendmail = '/usr/bin/sendmail';

my $subject = "Subject: Test Messagen\n";
my $content = "Thanks for your submission.\n";
my $to = "To: me@domain.net\n";


open(SENDMAIL, "|$sendmail -oi -t") or die ("Cannot open $sendmail: $!");
print SENDMAIL "From: email@mydomain.com\n";
print SENDMAIL $to;
print SENDMAIL $subject;
print SENDMAIL $content;
close(SENDMAIL);

print "DONE.\n";

bensheppard
03-15-2007, 06:54 AM
I have seen in the official support FAQ's that the path to sendmail is "usr/sbin/sendmail" ... however, I still get the same error when trying to do exactly what you're doing.
I hope someone finds an answer to this

bensheppard
03-18-2007, 07:45 PM
Ok, as an update, Put a recipient on the sendmail execution string and you lose that error.
e.g.
open(SENDMAIL, "|$sendmail recipient@host.com")
although this does remove the error, for some reason it still doesn't send the email.

c4r
06-05-2007, 02:35 PM
anyone ever get this figured out??? I'm stuck!

Thx.

c4r
06-07-2007, 07:21 AM
This is the code that worked for me:

open (SENDMAIL, "| /usr/sbin/sendmail -oi -t" );
print SENDMAIL "From: name <no_reply\@domain.com>\n";
print SENDMAIL "To: to\@domain.com\n";
print SENDMAIL "CC: cc\@domain.com\n";
print SENDMAIL "Subject: Subj goes here\n";
print SENDMAIL "Content-type: text/html\n\n";

rint SENDMAIL "<html>";
print SENDMAIL "<head></head>";
print SENDMAIL qq|<BODY>Message body</body></html>|;
print SENDMAIL "\n.\n";
close (SENDMAIL);


Hope it helps....