Adding proof of concept bounce processing postfix pipe script.
This commit is contained in:
parent
ef172e2228
commit
b6d18e88a2
3 changed files with 73 additions and 109 deletions
|
|
@ -141,8 +141,7 @@ sub send {
|
||||||
my $subject = '[TEST] Subject selection still needs to be implemented.';
|
my $subject = '[TEST] Subject selection still needs to be implemented.';
|
||||||
|
|
||||||
my $messageId = $id->toHex( $self->getId );
|
my $messageId = $id->toHex( $self->getId );
|
||||||
# TODO: MAKE DOMAIN SETTABLE!
|
my $domain = $session->setting->get( 'newsletterReturnDomain' );
|
||||||
my $domain = 'geefmegeld.nl';
|
|
||||||
|
|
||||||
# Setup email
|
# Setup email
|
||||||
my $mail = WebGUI::Mail::Send->create( $session, {
|
my $mail = WebGUI::Mail::Send->create( $session, {
|
||||||
|
|
@ -168,5 +167,18 @@ sub send {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub registerBounced {
|
||||||
|
my $self = shift;
|
||||||
|
|
||||||
|
$self->update( {
|
||||||
|
status => 'error',
|
||||||
|
errorMessage => 'Message was bounced',
|
||||||
|
} );
|
||||||
|
|
||||||
|
#### TODO: Write to bounce log
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
package WebGUI::Newsletter::Admin;
|
|
||||||
|
|
||||||
use strict;
|
|
||||||
use warnings;
|
|
||||||
use Carp 'confess';
|
|
||||||
|
|
||||||
use WebGUI::Asset;
|
|
||||||
use WebGUI::AdminConsole;
|
|
||||||
|
|
||||||
sub getAdminConsole {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
my $ac = WebGUI::AdminConsole->new( $self->session );
|
|
||||||
|
|
||||||
return $ac;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub getMailables {
|
|
||||||
my $self = shift;
|
|
||||||
|
|
||||||
return WebGUI::Asset->getRoot( $self->session )->getLineage( ['descendants'], {
|
|
||||||
returnObjects => 1,
|
|
||||||
whereClause => 'assetData.assetId in (select distinct assetId from assetAspectMailable)',
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
sub new {
|
|
||||||
my $class = shift;
|
|
||||||
my $session = shift || confess 'No session passed';
|
|
||||||
|
|
||||||
bless { _session => $session }, $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub session {
|
|
||||||
return (shift)->{ _session };
|
|
||||||
}
|
|
||||||
|
|
||||||
sub www_createMailing {
|
|
||||||
my $self = shift;
|
|
||||||
my $session = $self->session;
|
|
||||||
my $form = $session->form;
|
|
||||||
|
|
||||||
# TODO: test if assetId and issueId are valid.
|
|
||||||
my $assetId = $form->guid( 'assetId' );
|
|
||||||
my $issueId = $form->guid( 'issueId' );
|
|
||||||
|
|
||||||
my $mailing = WebGUI::Mailing->create( $session, {
|
|
||||||
assetId => $assetId,
|
|
||||||
issueId => $issueId,
|
|
||||||
active => 0,
|
|
||||||
} );
|
|
||||||
|
|
||||||
return $self->www_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub www_view {
|
|
||||||
my $self = shift;
|
|
||||||
my $session = $self->session;
|
|
||||||
my $url = $session->url;
|
|
||||||
|
|
||||||
my $letters = $self->getMailables;
|
|
||||||
|
|
||||||
my @newsletterLoop;
|
|
||||||
foreach my $letter ( @{ $letters } ) {
|
|
||||||
my $letterId = $letter->getId;
|
|
||||||
|
|
||||||
my @issues;
|
|
||||||
foreach my $issue ( @{ $letter->getIssues } ) {
|
|
||||||
my $issueId = $issue->getId;
|
|
||||||
|
|
||||||
my @mailings;
|
|
||||||
my $it = WebGUI::Mailing->getAllIterator( $session, { sequenceKeyValue => $issueId } );
|
|
||||||
while ( my $mailing = $it->() ) {
|
|
||||||
push @mailings, {
|
|
||||||
%{ $mailing->get },
|
|
||||||
status => $mailing->getStatusLine,
|
|
||||||
sendTestUrl => $url->page('newsletter=mailing;func=sendTestEmails;id='.$mailing->getId),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
push @issues, {
|
|
||||||
%{ $issue->get },
|
|
||||||
url => $issue->getUrl,
|
|
||||||
createMailingUrl => $url->page("newsletter=manage;func=createMailing;assetId=$letterId;issueId=$issueId"),
|
|
||||||
previewUrl => $letter->getUrl( "func=previewEmail;issueId=$issueId" ),
|
|
||||||
editUrl => $issue->getUrl( 'func=edit' ),
|
|
||||||
sendUrl => '',
|
|
||||||
sendTestUrl => '',
|
|
||||||
mailing_loop => \@mailings,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
push @newsletterLoop, {
|
|
||||||
%{ $letter->get },
|
|
||||||
issue_loop => \@issues,
|
|
||||||
issueCount => scalar( @issues ),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
my $var = { newsletter_loop => \@newsletterLoop };
|
|
||||||
|
|
||||||
my $template = WebGUI::Asset::Template->new( $self->session, 'FTfNhWI8KJOwLzFUl5rYeQ' );
|
|
||||||
return $self->getAdminConsole->render( $template->process( $var ), 'Manage newsletters' );
|
|
||||||
}
|
|
||||||
|
|
||||||
1;
|
|
||||||
|
|
||||||
59
sbin/newsletter-transport.pl
Executable file
59
sbin/newsletter-transport.pl
Executable file
|
|
@ -0,0 +1,59 @@
|
||||||
|
#!/data/wre/prereqs/bin/perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
unshift @INC, qw(
|
||||||
|
/data/custom/webgui_newsletter/lib
|
||||||
|
/data/WebGUI/lib
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
use WebGUI::Mailing::Email;
|
||||||
|
use List::MoreUtils qw{ any };
|
||||||
|
|
||||||
|
|
||||||
|
my $NO_SUCH_USER = 67;
|
||||||
|
my $webguiRoot = '/data/WebGUI';
|
||||||
|
my $configFile = 'martintwee.oqapi.nl.conf';
|
||||||
|
|
||||||
|
|
||||||
|
my ( $domain, $user ) = @ARGV;
|
||||||
|
my ( $listname, $command ) = $user =~ m{^(.+)-([^-]+)$}i;
|
||||||
|
|
||||||
|
#exit $NO_SUCH_USER unless any { $command eq $_ } qw{ subscribe unsubscribe bounces confirm };
|
||||||
|
|
||||||
|
|
||||||
|
open my $log, '>>/data/test.log' || die "Cannot open log";
|
||||||
|
|
||||||
|
unless ( any { $command eq $_ } qw{ subscribe unsubscribe bounce confirm } ) {
|
||||||
|
print $log "Ignoring $domain $user\n";
|
||||||
|
close $log;
|
||||||
|
exit $NO_SUCH_USER;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $session = WebGUI::Session->open($webguiRoot,$configFile);
|
||||||
|
my $email = WebGUI::Mailing::Email->new( $session, $session->id->fromHex( $listname ) );
|
||||||
|
|
||||||
|
if ($email) {
|
||||||
|
print $log "Found email instance\n";
|
||||||
|
$email->registerBounced;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print $log "Can't find email instance\n";
|
||||||
|
}
|
||||||
|
$session->close;
|
||||||
|
}
|
||||||
|
|
||||||
|
local $/;
|
||||||
|
my $content = <STDIN>;
|
||||||
|
|
||||||
|
print $log "listname: $listname, command: $command\n";
|
||||||
|
#print $log "content: $content\n";
|
||||||
|
|
||||||
|
print $log "\n\n\n\n ================================================================================\n\n\n\n";
|
||||||
|
|
||||||
|
close $log;
|
||||||
|
|
||||||
|
exit $NO_SUCH_USER unless any { $command eq $_ } qw{ subscribe unsubscribe bounces confirm };
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue