Also, you have a global %mail hash, which will stay the same for every PL::Mail object you create, which probably isnt what you want.. To make it unique per object, you need to store that data in $self.
Also you need to be very careful about case sensitivity, $self->{SUBJECT} and $self->{subject} are not the same thing.
Here is an attempt at repair:
package PL::Mail; use strict; use Mail::Sendmail; ## Only global is your server since it doesnt change (?) my $server = 'pop.dnvr.qwest.net'; ## The new constructor just sets up the server and the From address si +nce these are static (could put the server name here directly and not + have a global variable) sub new { my $class = shift; my $self = {}; $self->{mail}{Smtp} = $server; $self->{mail}{From} = 'Postmaster <noreply@dhoss.cjb.net>'; bless $self, $class; return $self; } ## The send method is passed a hashref, containing subject, message an +d optionally a to key. ## eg $obj->send({subject => 'testing', message => 'just trying to sen +d mail', to => 'me'}); ## The $self hashref, which represents the object, is used to store al +l the parts of the %mail hash, which is then passed to sendmail sub send { my ($self, $data) = @_; $self->{mail}{To} = $data->{to} ? $self->{to} : 'Devin Austi +n <devin.austin@gmail.com>'; $self->{mail}{Subject} = $data->{subject}; $self->{mail}{Message} = $data->{message}; my $date = Mail::Sendmail::time_to_date(); $self->{mail}{Message} .= <<"" Message sent on $date From $ENV{REMOTE_ADDR} All information contained in this message do not reflect the ideas of Devin Austin or MorningStarWeb and it's affiliates. ; if (sendmail %{$self->{mail}) { print STDERR $Mail::Sendmail::error; } else { print STDERR "Error sending mail ($date): $!"; } }
C.
In reply to Re: problematic OO
by castaway
in thread problematic OO
by stonecolddevin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |