From 0050f44bec84ae251238ac047f6deb9840521031 Mon Sep 17 00:00:00 2001 From: khenn Date: Mon, 26 Apr 2010 12:45:30 -0500 Subject: [PATCH] Added a way to pass additional headers to WebGUI::Mail::Send from the WebGUI::Inbox::Message API --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Inbox/Message.pm | 27 ++++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 82c18dfc1..4c4e1bd65 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -2,6 +2,7 @@ - fixed #11535: i18n - Asset_MapPoint - Tag form_fax - wrong text - Implement hierarchial keywords differently. - fixed Redundant per item address display in cart. +- added a way to pass additional headers to WebGUI::Mail::Send from WebGUI::Inbox::Message API 7.9.3 - added #11477: No synopsis in asset now means no synopsis in search index diff --git a/lib/WebGUI/Inbox/Message.pm b/lib/WebGUI/Inbox/Message.pm index 642aed264..bcbf13d5b 100644 --- a/lib/WebGUI/Inbox/Message.pm +++ b/lib/WebGUI/Inbox/Message.pm @@ -129,6 +129,11 @@ per-user settings for email delivery will not be used. Useful if you want to for be sent as an Email rather than allowing the user's C setting to take effect. +=head4 extraHeaders + +A hash ref containing extra header information to send to WebGUI::Message::create valid headers include: +cc, bcc, replyTo, returnPath, contentType, messageId, and inReplyTo. See WebGUI::Message::create for more details. + =cut sub create { @@ -186,13 +191,21 @@ sub create { } unless ( $options->{ no_email } ) { my $subject = (defined $properties->{emailSubject}) ? $properties->{emailSubject} : $self->{_properties}{subject}; - my $mail = WebGUI::Mail::Send->create($session, { - toUser=>$self->{_properties}{userId}, - toGroup=>$self->{_properties}{groupId}, - subject=>$subject, - }, - $options->{overridePerUserDelivery} ? undef : 'isInbox', - ); + #Set default mail headers + my $mailHeaders = { + toUser=>$self->{_properties}{userId}, + toGroup=>$self->{_properties}{groupId}, + subject=>$subject, + }; + #Add extraHeaders if they are passsed in as options + if($options->{ extraHeaders } && ref $options->{ extraHeaders } eq 'HASH') { + %{$mailHeaders} = (%{$mailHeaders},%{$options->{ extraHeaders }}); + } + #Get inbox override flag + my $overridePerUserDelivery = $options->{overridePerUserDelivery} ? undef : 'isInbox'; + #Create the mail message + my $mail = WebGUI::Mail::Send->create($session,$mailHeaders,$overridePerUserDelivery); + my $preface = ""; my $fromUser = WebGUI::User->new($session, $properties->{sentBy}); #Don't append prefaces to the visitor users or messages that don't specify a user (default case)