Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

Hi,

I want to send mail from my solaris machine using perl.
I used couple of examples available online but none of them worked for me.
Is there any specefic configuration to be done to use the commands like mail/mailx?

Suggest some alternate options to do the same.
Thanks and regards,
Ramesh.


sample script to sending an email using perl

#!/usr/bin/perl
print "Content-type: text/html\n\n";

$title='Perl Mail demo';
$to='MAIL ADDRESS TO SEND TO';
$from= 'webmaster@YOURDOMAIN.COM';
$subject='YOUR SUBJECT';

open(MAIL, "|/usr/sbin/sendmail -t");

## Mail Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
## Mail Body
print MAIL "This is a test message from Cyberciti.biz! You can write your
mail body text here\n";

close(MAIL);

Robert Lee Binkley Jr

Re: How to send mail from perl on Solaris 10

How did you write the script? Did you use Mail::Send as in this example?

You have to be sure first that your Solaris box can properly send mail; is sendmail configured correctly?