# 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
[tt]
open (MAIL, "| /usr/sbin/sendmail -t >& /dev/null");
[/tt]
# 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>
[tt]
print MAIL qq~To: "$title" <$email_addr>\n~;
[/tt]
# If you want to send to a list, send the mail only once,
# but make each address a blind carbon copy.
[tt]
print MAIL qq~Bcc: ~;
my $address = pop(@LIST);
print MAIL qq~$address~;
foreach $address (@LIST) {print MAIL qq~, $address~;}
[/tt]
# Include the remaining header info
[tt]
print MAIL qq~\nFrom: "$return_name" <$return_addr>\n~;
print MAIL qq~Reply-To: $return_addr\n~;
print MAIL qq~List-Unsubscribe: $return_addr\n~;
print MAIL qq~Subject: $subject\n~;
[/tt]
# 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.
[tt]
print MAIL qq~Content-Type: text/plain\n\n~;
[/tt]
# Then, print the body of your email to the mail stream
[tt]
print MAIL qq~$body_text\n~;
[/tt]
# 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.
[tt]
print MAIL qq~.~;
[/tt]
# 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.
[tt]
close(MAIL);
[/tt]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.