- fix: cs mail needs archive url

- fix: cs mail not sending in-reply-to and references headers
 - fix: cs mail doesn't like code via email
 - CS mail now sends out the email address of the poster as from, when it 
   exists.
This commit is contained in:
JT Smith 2006-07-19 18:37:33 +00:00
parent 534855ddc8
commit 45080ea0d9
5 changed files with 116 additions and 17 deletions

View file

@ -27,6 +27,11 @@
privs to the storage associated with it. (Martin Kamerbeek / Procolix) privs to the storage associated with it. (Martin Kamerbeek / Procolix)
- Added a reverse page loop option to the navigation asset (Martin - Added a reverse page loop option to the navigation asset (Martin
Kamerbeek / Procolix) Kamerbeek / Procolix)
- fix: cs mail needs archive url
- fix: cs mail not sending in-reply-to and references headers
- fix: cs mail doesn't like code via email
- CS mail now sends out the email address of the poster as from, when it
exists.
- fix: WebGUI::Image missing methods - fix: WebGUI::Image missing methods
- Added runOnLogin and runOnLogout config file properties to Authentication to allow - Added runOnLogin and runOnLogout config file properties to Authentication to allow
for running an external script on successful login or logout. for running an external script on successful login or logout.

View file

@ -629,29 +629,74 @@ sub notifySubscribers {
my $self = shift; my $self = shift;
my $i18n = WebGUI::International->new($self->session); my $i18n = WebGUI::International->new($self->session);
my $var = $self->getTemplateVars(); my $var = $self->getTemplateVars();
$self->getThread->getParent->appendTemplateLabels($var); my $thread = $self->getThread;
$var->{url} = $self->session->url->getSiteURL().$self->getUrl; my $cs = $thread->getParent;
$cs->appendTemplateLabels($var);
my $siteurl = $self->session->url->getSiteURL();
$var->{url} = $siteurl.$self->getUrl;
$var->{'notify.subscription.message'} = $i18n->get(875,"Asset_Post"); $var->{'notify.subscription.message'} = $i18n->get(875,"Asset_Post");
my $message = $self->processTemplate($var, $self->getThread->getParent->get("notificationTemplateId")); my $message = $self->processTemplate($var, $cs->get("notificationTemplateId"));
my $unsubscribe = '<p><a href="'.$self->getThread->getParent->getUnsubscribeUrl.'">'.$i18n->get("unsubscribe","Asset_Collaboration").'</a></p>'; my $unsubscribe = '<p><a href="'.$siteurl.$cs->getUnsubscribeUrl.'">'.$i18n->get("unsubscribe","Asset_Collaboration").'</a></p>';
my $from = $self->getThread->getParent->get("mailAddress"); my $user = WebGUI::User->new($self->session, $self->get("ownerUserId"));
my $subject = $self->getThread->getParent->get("mailPrefix").$self->get("title"); my $from = $user->profileField("email") || $cs->get("mailAddress");
my $replyTo = $cs->get("mailAddress");
my $setting = $self->session->setting;
my $listId = $cs->get("mailAddress");
$listId =~ s/\@/\./;
my $domain = $cs->get("mailAddress");
$domain =~ s/.*\@(.*)/$1/;
my $messageId = "cs-".$self->getId.'@'.$domain;
my $replyId = "";
if ($self->isReply) {
$replyId = "cs-".$self->getParent->getId.'@'.$domain;
}
my $subject = $cs->get("mailPrefix").$self->get("title");
my $mail = WebGUI::Mail::Send->create($self->session, { my $mail = WebGUI::Mail::Send->create($self->session, {
from=>$from, from=>"<".$from.">",
toGroup=>$self->getThread->getParent->get("subscriptionGroupId"), replyTo=>"<".$replyTo.">",
toGroup=>$cs->get("subscriptionGroupId"),
subject=>$subject, subject=>$subject,
messageId=>"cs-".$self->getId messageId=>$messageId
}); });
if ($self->isReply) {
$mail->addHeaderField("In-Reply-To", "<".$replyId.">");
$mail->addHeaderField("References", "<".$replyId.">");
}
$mail->addHeaderField("List-ID", $cs->getTitle." <".$listId.">");
$mail->addHeaderField("List-Help", "<mailto:".$setting->get("companyEmail").">, <".$setting->get("companyURL").">");
$mail->addHeaderField("List-Unsubscribe", "<".$siteurl.$cs->getUnsubscribeUrl.">");
$mail->addHeaderField("List-Subscribe", "<".$siteurl.$cs->getSubscribeUrl.">");
$mail->addHeaderField("List-Owner", "<mailto:".$setting->get("companyEmail").">, <".$setting->get("companyURL")."> (".$setting->get("companyName").")");
$mail->addHeaderField("List-Post", "<mailto:".$cs->get("mailAddress").">");
$mail->addHeaderField("List-Archive", "<".$siteurl.$cs->getUrl.">");
$mail->addHeaderField("X-Unsubscribe-Web", "<".$siteurl.$cs->getUnsubscribeUrl.">");
$mail->addHeaderField("X-Subscribe-Web", "<".$siteurl.$cs->getSubscribeUrl.">");
$mail->addHeaderField("X-Archives", "<".$siteurl.$cs->getUrl.">");
$mail->addHtml($message.$unsubscribe); $mail->addHtml($message.$unsubscribe);
$mail->addFooter; $mail->addFooter;
$mail->queue; $mail->queue;
my $mail = WebGUI::Mail::Send->create($self->session, { my $mail = WebGUI::Mail::Send->create($self->session, {
from=>$from, from=>"<".$from.">",
toGroup=>$self->getThread->get("subscriptionGroupId"), replyTo=>"<".$replyTo.">",
toGroup=>$thread->get("subscriptionGroupId"),
subject=>$subject, subject=>$subject,
messageId=>"cs-".$self->getId messageId=>$messageId
}); });
$unsubscribe = '<p><a href="'.$self->getThread->getUnsubscribeUrl.'">'.$i18n->get("unsubscribe","Asset_Collaboration").'</a></p>'; $unsubscribe = '<p><a href="'.$siteurl.$thread->getUnsubscribeUrl.'">'.$i18n->get("unsubscribe","Asset_Collaboration").'</a></p>';
if ($self->isReply) {
$mail->addHeaderField("In-Reply-To", "<".$replyId.">");
$mail->addHeaderField("References", "<".$replyId.">");
}
$mail->addHeaderField("List-ID", $cs->getTitle." <".$listId.">");
$mail->addHeaderField("List-Help", "<mailto:".$setting->get("companyEmail").">, <".$setting->get("companyURL").">");
$mail->addHeaderField("List-Unsubscribe", "<".$siteurl.$thread->getUnsubscribeUrl.">");
$mail->addHeaderField("List-Subscribe", "<".$siteurl.$thread->getSubscribeUrl.">");
$mail->addHeaderField("List-Owner", "<mailto:".$setting->get("companyEmail").">, <".$setting->get("companyURL")."> (".$setting->get("companyName").")");
$mail->addHeaderField("List-Post", "<mailto:".$cs->get("mailAddress").">");
$mail->addHeaderField("List-Archive", "<".$siteurl.$cs->getUrl.">");
$mail->addHeaderField("X-Unsubscribe-Web", "<".$siteurl.$thread->getUnsubscribeUrl.">");
$mail->addHeaderField("X-Subscribe-Web", "<".$siteurl.$thread->getSubscribeUrl.">");
$mail->addHeaderField("X-Archives", "<".$siteurl.$cs->getUrl.">");
$mail->addHtml($message.$unsubscribe); $mail->addHtml($message.$unsubscribe);
$mail->addFooter; $mail->addFooter;
$mail->queue; $mail->queue;

View file

@ -157,12 +157,12 @@ sub format {
$content =~ s/&/&amp;/g; $content =~ s/&/&amp;/g;
$content =~ s/\</&lt;/g; $content =~ s/\</&lt;/g;
$content =~ s/\>/&gt;/g; $content =~ s/\>/&gt;/g;
$content =~ s/\n/\<br \/\>/g; $content =~ s/\n/\<br \/\>\n/g;
$content =~ s/\t/&nbsp;&nbsp;&nbsp;&nbsp;/g; $content =~ s/\t/&nbsp;&nbsp;&nbsp;&nbsp;/g;
} }
if ($contentType eq "mixed") { if ($contentType eq "mixed") {
unless ($content =~ /\<div/ig || $content =~ /\<br/ig || $content =~ /\<p/ig) { unless ($content =~ /\<div/ig || $content =~ /\<br/ig || $content =~ /\<p/ig) {
$content =~ s/\n/\<br \/\>/g; $content =~ s/\n/\<br \/\>\n/g;
} }
} elsif ($contentType eq "text") { } elsif ($contentType eq "text") {
$content =~ s/ / &nbsp;/g; $content =~ s/ / &nbsp;/g;

View file

@ -94,6 +94,30 @@ sub addFooter {
$self->addText($text); $self->addText($text);
} }
#-------------------------------------------------------------------
=head2 addHeaderField ( name, value )
Adds a header field to the mail message. See also replaceHeaderField().
=head3 name
The name of the field to add.
=head3 value
The value of the field to add.
=cut
sub addHeaderField {
my $self = shift;
my $name = shift;
my $value = shift;
$self->{_message}->head->add($name, $value);
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 addHtml ( html ) =head2 addHtml ( html )
@ -219,7 +243,7 @@ sub create {
my $from = $headers->{from} || $session->setting->get("companyEmail"); my $from = $headers->{from} || $session->setting->get("companyEmail");
my $type = $headers->{contentType} || "multipart/mixed"; my $type = $headers->{contentType} || "multipart/mixed";
my $domain = $from; my $domain = $from;
$domain =~ s/\@(.*)/$1/; $domain =~ s/.*\@(.*)/$1/;
my $id = $headers->{messageId} || "WebGUI-".$session->id->generate; my $id = $headers->{messageId} || "WebGUI-".$session->id->generate;
unless ($id =~ m/\@/) { unless ($id =~ m/\@/) {
$id .= '@'.$domain; $id .= '@'.$domain;
@ -285,6 +309,30 @@ sub queue {
} }
#-------------------------------------------------------------------
=head2 replaceHeaderField ( name, value )
Replaces an existing header field in the mail message, or creates it if it doesn't exist. See also addHeaderField().
=head3 name
The name of the field to replace.
=head3 value
The value of the field to replace.
=cut
sub replaceHeaderField {
my $self = shift;
my $name = shift;
my $value = shift;
$self->{_message}->head->replace($name, $value);
}
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 retrieve ( session, messageId ) =head2 retrieve ( session, messageId )

View file

@ -20,6 +20,7 @@ use base 'WebGUI::Workflow::Activity';
use WebGUI::Mail::Get; use WebGUI::Mail::Get;
use WebGUI::Mail::Send; use WebGUI::Mail::Send;
use WebGUI::Asset; use WebGUI::Asset;
use WebGUI::HTML;
use WebGUI::International; use WebGUI::International;
use WebGUI::User; use WebGUI::User;
@ -78,7 +79,7 @@ sub addPost {
if (($part->{type} =~ /^text\/plain/ || $part->{type} =~ /^text\/html/) && $part->{filename} eq "") { if (($part->{type} =~ /^text\/plain/ || $part->{type} =~ /^text\/html/) && $part->{filename} eq "") {
my $text = $part->{content}; my $text = $part->{content};
if ($part->{type} eq "text/plain") { if ($part->{type} eq "text/plain") {
$text =~ s/\n/\<br \/\>/g; $text = WebGUI::HTML::format($text, "text");
} }
$content .= $text; $content .= $text;
} else { } else {