coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Monday September 6, 2010


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?
Create an account

Who's Online
We have 24 guests online

Newest Member

Starmamex

Hit Counter
4760785 Visitors

cool Statistics
coolcommands:1313
Categories:82
Total queries:523831
Members:4281





Search coolcommands.com
Search Keyword:


coolcommand

perl script to send mail using perl standard installation
Description


#!/usr/bin/perl
use Socket;

$smtp_server = 'smtpservername';
@toliste = ('user2@test.com','user2@test.com');
$from = 'test@test.com';
$subject = "testsubject";
$body = "testbody";

if ($#toliste!="")
{
foreach $recipient (@toliste)
{
print "Send to: ".$recipient."\n";
send_mail ($from, $recipient, $subject, $body);
}
}

sub send_mail {

my ( $from , $to , $subject , $body ) = @_;

$body =~ s/\n\.[\r|\n]/\n. $1/g;

my $proto = getprotobyname('tcp');
socket(SERVER, AF_INET, SOCK_STREAM, $proto);
my $iaddr = gethostbyname($smtp_server);
my $port = getservbyname('smtp', 'tcp');
my $sin = sockaddr_in($port, $iaddr);

my $sreply;

connect(SERVER, $sin);
recv SERVER, $sreply, 512, 0;

send SERVER, "HELO $smtp_server\r\n", 0;
recv SERVER, $sreply, 512, 0;

send SERVER, "MAIL From:<$from>\r\n", 0;
recv SERVER, $sreply, 512, 0;

send SERVER, "RCPT To:<$to>\r\n", 0;
recv SERVER, $sreply, 512, 0;

send SERVER, "DATA\r\n", 0;
recv SERVER, $sreply, 512, 0;

send SERVER, "Subject: $subject\r\n", 0;
send SERVER, "\r\n$body\r\n", 0;
send SERVER, ".\r\n", 0;
recv SERVER, $sreply, 512, 0;

send SERVER, "QUIT\r\n", 0;
recv SERVER, $sreply, 512, 0;
close SERVER;
}
Example

standard_perl_mail.pl

Return to search results

Random coolcommands

coolcommand: lsps - to check swap space in IBM AIX
Example: lsps -a
[show me the details]
coolcommand: cfgmgr - how to add devices without rebooting in IBM AIX
Example: cfgmgr -v
[show me the details]
coolcommand: DB2 - license information on IBM AIX
Example: /var/ifor/nodelock; /var/ifor/*
[show me the details]
coolcommand: mktcpip - how to configure a tcpip interface in IBM AIX
Example: mktcpip -haixserv1 -a172.26.25.68 -m255.255.255.0 -ien0 -n172.120.17.100 -dmydomain.com -g172.26.25.1
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1138
audet37
kah00na32
Mariom24
lebjf00013

Top 5 Searches

Category Solaris42690
Category AIX38082
Category General UNIX34254
solaris20802
aix19388

Terms of Use
Privacy
Contact


 
coolcommands.com © 2010. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum