
200mg
New User
May 29, 2009, 11:49 AM
Post #3 of 4
(4785 views)
|
Re: [FishMonger] Insert Variable into Subject Line using Mail::Sendmail
[In reply to]
|
Can't Post
|
|
Do you mean this? Subject => 'Test message', I'm trying to get a variable into the 'Test message' part. The code below send "$var1" as the subject instead of the variable. use warnings; use strict; use Mail::Sendmail; my $var1 = "Test"; print "Testing Mail::Sendmail version $Mail::Sendmail::VERSION\n"; print "Default server: $Mail::Sendmail::mailcfg{smtp}->[0]\n"; print "Default sender: $Mail::Sendmail::mailcfg{from}\n"; my %mail = ( To => 'bob_jones@harte-hanks.com', From => 'bob_jones@harte-hanks.com', #Bcc => 'Someone <him@there.com>, Someone else her@there.com', # only addresses are extracted from Bcc, real names disregarded #Cc => 'Yet someone else <xz@whatever.com>', # Cc will appear in the header. (Bcc will not) Subject => '$var1', Message => '?', 'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION", ); my $var1 = "Test"; $mail{Smtp} = 'smtp.harte-hanks.com'; $mail{'X-custom'} = 'My custom additionnal header'; $mail{'mESSaGE : '} = "The message key looks terrible, but works."; # cheat on the date: $mail{Date} = Mail::Sendmail::time_to_date( time() - 86400 ); if (sendmail %mail) { print "Mail sent OK.\n" } else { print "Error sending mail: $Mail::Sendmail::error \n" } print "\n\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log;
|