Hello,
I'm attempting to use faq for sending mail using sendmail:
I am getting a "broken pipe" error. Maybe another set of eyes will catch my error. Thanks in advance for any and all help.
I'm attempting to use faq for sending mail using sendmail:
I am getting a "broken pipe" error. Maybe another set of eyes will catch my error. Thanks in advance for any and all help.
Code:
#!/usr/bin/perl
# Open a stream, piped to your sendmail program. You
# should send the process to the background and send all
# output to /dev/null so that your program does not hang
# if the mail queue takes awhile
$title="LOC Retrieval";
$subject="LOC Retrieval";
$email_addr="kelly.brax@.suny.edu";
$return_name="LOC";
$return_addr="val@suny.edu";
open (MAIL, "| /usr/sbin/sendmail -t >& /dev/null");
# Print the To: field to your mail stream. You can either
# enter the recipient email by itself, or in the standard
# format of Name <address>
print MAIL qq~To: "$title" <$email_addr>\n~;
# If you want to send to a list, send the mail only once,
# but make each address a blind carbon copy.
#print MAIL qq~Bcc: ~;
#my $address = pop(@LIST);
#print MAIL qq~$address~;
#foreach $address (@LIST) {print MAIL qq~, $address~;}
# Include the remaining header info
print MAIL qq~\nFrom: "$return_name" <$return_addr>\n~;
print MAIL qq~Reply-To: $return_addr\n~;
print MAIL qq~Subject: $subject\n~;
# To send HTML formatted emails, your Content-Type needs
# to be text/html. Otherwise it is text/plain. This being
# the last line before the body, there are two newlines at
# the end of this line.
print MAIL qq~Content-Type: text/plain\n\n~;
# Then, print the body of your email to the mail stream
$body_text="test";
print MAIL qq~$body_text\n~;
# And close with a period on a line of its own. This is
# not necessary, since the mail will send when you close
# the stream, but it is the correct sendmail format.
print MAIL qq~.~;
# Close your mail stream, and your email will be sent to
# the sendmail queue to be sent out. Sendmail will figure
# out the best way of doing this for you. If you have a
# large list, it may send a few emails every few minutes.
close(MAIL);