in reply to Setting subject with Net::SMTP

No, because that's part of the message body you pass whole to it. Perhaps you might want something a bit higher level, such as Mail::Send or Mail::Mailer?

Update: Aristotle is correct, the subject is one of the message headers. More correctly I should have said "part of the message contents you pass whole to it", since Net::SMTP doesn't have separate methods for sending headers and sending the body.

Replies are listed 'Best First'.
Re^2: Setting subject with Net::SMTP
by Aristotle (Chancellor) on Jul 26, 2004 at 18:30 UTC
    Actually, it's part of the headers.

    Makeshifts last the longest.

Re^2: Setting subject with Net::SMTP
by jimbobfurley (Novice) on Jul 26, 2004 at 18:23 UTC
    I forgot to mention that I am coding this in ActiveState's Win32 implementation ... (i.e. no Mail::Send and no Mail::Mailer) What do you mean by "that's part of the message body you pass whole to it" ? This is what I have so far :
    use strict; use Net::SMTP; use FileHandle; my $smtp = Net::SMTP->new('mailhost', Hello => 'exchange.cognos.com', Timeout => 30, Debug => 1, ); my $fh_email_title= new FileHandle; $fh_email_title->open("< email_title.txt") or die "Cannot open email title file: $!"; my $fh_email_content= new FileHandle; $fh_email_content->open("< email_content.txt") or die "Cannot open email content file: $!"; $smtp->mail('travis.weir@cognos.com'); $smtp->to('travis.weir@cognos.com'); $smtp->???($fh_email_title->getlines()); $smtp->data(); $smtp->datasend($fh_email_content->getlines()); $smtp->dataend(); $fh_email_title->close; $fh_email_content->close; $smtp->quit; autoflush STDOUT 1;
    Again, I'm not sure what you meant by your earlier statement .... Thanks again, Travis

      When you call $smtp->datasend, you're passing the entire message body headers and all. SMTP doesn't have any notion of a messaage subject; the mail and to methods are setting the envelope sender and receiver, but those aren't duplicated inside the body of the message unless you explicitly do so yourself (by calling datasend with "From: ...\n" and the like). If you want to set a subject, just pass datasend a line "Subject: blah\n" somewhere before the body of the message.