New module send email to agent

English! place to talk about development, programming and coding
Post Reply
daniela1611
Znuny newbie
Posts: 4
Joined: 10 May 2012, 03:26
Znuny Version: 3.2.6
Real Name: Daniela Gutierrez

New module send email to agent

Post by daniela1611 »

Hi, I'm building a new module that let the customer make an appointment with the agent in case the ticket is not successfully closed.
I have the form and everything but can't figure out how to send an email, I'm using this code to test:

Code: Select all

  if ( $Self->{Subaction} eq 'NotifyAgent' ) {
        my $EmailObject = Kernel::System::Email->new( %{$Self} );
        my $Body = "Test";
        my $Subject = "Test";
        my $Sent = $EmailObject->Send(
            To       => "test\@test.com",
            Subject  => $Subject,
            Charset  => $Self->{LayoutObject}->{UserCharset},
            MimeType => 'text/plain',
            Body     => $Body
        );
        if ( !$Sent ) {
            $Self->{LayoutObject}->FatalError(
                Comment => 'Please contact your administrator'
            );
            return;
        }
 return 1;
}

It's not working and I get this in the apache's log :

malformed header from script. Bad header=1("message5", function(data) {: customer.pl, referer: https://mydomain.com/otrs/customer.pl?A ... ateBooking
/otrs/customer.pl did not send an HTTP header

Maybe some of you know what I'm doing wrong or maybe I'f there is something that can be done via Agent Interface.... any help would be appreciated.

Thanks
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: New module send email to agent

Post by reneeb »

If this is code from Kernel/Modules/*.pm, you must not return "1" but HTML. Look at all the other frontend modules and you'll find something like

Code: Select all

my $Output = $Self->{LayoutObject}->Header();
$Output .= ...
return $Output;
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
Post Reply