[freeside] Email not being sent

Rick Eicher II rick at pbol.net
Wed Mar 6 09:40:24 PST 2002


After trying everything I could think of I inserted my code into
cust_bill.pm

And it will not send out the email.

My code is as follows.


########################################################
  my $self = shift;

  #my @print_text = $cust_bill->print_text; #( date )
  my @invoicing_list = $self->cust_main->invoicing_list;
  if ( grep { $_ ne 'POST' } @invoicing_list ) { #email invoice
    $ENV{SMTPHOSTS} = $smtpmachine;
    $ENV{MAILADDRESS} = $invoice_from;

    my $smtp = Net::SMTP->new($smtpmachine);
    die "Couldn't connect to server" unless $smtp;


    $smtp->mail($invoice_from);
    $smtp->to($invoice_from);
    $smtp->data();
    $smtp->datasend("To: $invoice_from \n");
    $smtp->datasend("From: $invoice_from \n");
    $smtp->datasend("\n");
    $smtp->datasend([ $self->print_text ]);
    $smtp->dataend();
    $smtp->quit;

    # my $header = new Mail::Header ( [
    #  "From: $invoice_from",
    #  "To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ),
    #  "Sender: $invoice_from",
    #  "Reply-To: $invoice_from",
    #  "Date: ". time2str("%a, %d %b %Y %X %z", time),
    #  "Subject: Invoice",
    #] );
    #my $message = new Mail::Internet (
     #  'Header' => $header,
    #  'Body' => [ $self->print_text ], #( date)
    #   Debug => 1,
    #);
    #$message->smtpsend
    #  or return "(customer # ". $self->custnum. ") can't send invoice
email".
    #            " for ". join(', ', grep { $_ ne 'POST' }
@invoicing_list ).
    #            " to server $ENV{SMTPHOSTS}!";

  #} elsif ( grep { $_ eq 'POST' } @invoicing_list ) {
  } elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
############################################################################
##

However it will not send the body of the email invoice all I get is.

	[ FS::cust_bill=HASH(0x8c5f5b8)->print_text ]

I have done this since I have to have a working system. Later I plan to go
back and look into this. But as it stands now I is send an email now. I just
need to get it to send the body of the message.

jw what is the advantage of the mail::internet over straight net::smtp?


Thanks,
rick






More information about the freeside-users mailing list