![]() |
|
Customer Support
How do I use sendmail with perl?
You can either specify who the mail will be sent to as you print to the MAIL filehandle like so:#!/usr/bin/perlor you can specify who the mail will be sent to as you invoke sendmail:
unless(open (MAIL, "|/usr/sbin/sendmail -t")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me\@mydom.com\n";
print MAIL "To: test\@testdom.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "test mail message";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent.\n";
}
#!/usr/bin/perl
unless(open (MAIL, "|/usr/sbin/sendmail recipient\@someplace.com")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else{
print MAIL "From: me\@mydom.com\n";
print MAIL "Subject: test subject\n\n";
print MAIL "test mail message";
close(MAIL) || warn "Error closing mail: $!";
print "Mail sent\n";
}
Related Questions:
How do I use cgi scripts?
My formmail.pl script from Matt's Script Archive doesn't work.
Why does Sbox say "no such file or directory" but the files are there?
What Perl modules are installed?
Do you offer CGI? What scripts can I install?
I can't get the python socket module to work?
Why do I get: Sbox error file is world writable?
What is the path to perl or some other program?
Sendmail does not work or does not accept my optional arguments.
Importing the Python cgi module doesn't work.
How do I use MySQL with Python?
What version of Python do you support and what modules are available?
Why do I get: Sbox Error exec of [some script] failed (Exec format error)?
Why do I get: Sbox error file not world executable?
Why do I get: Sbox error the directory containing [some script] is world writable?
Why do I get: Sbox Error exec of [some script] failed (Permission denied)
Why do I get: Sbox error: cannot run suid scripts
Why do I get: Sbox Error exec of [some script] failed (Resource temporarily unavailable)
Browse Categories:Getting Started, FTP, Telnet/SSH, Moving Domains, E-mail, Traffic Reports, Mailing Lists, Apache, PHP, CGI, Other Server-Side Scripting, MySQL Database, Imaging Libraries, Other Software, Billing & Terms, Control Panel, E-commerce, Pre-Sales |

