- 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:
parent
534855ddc8
commit
45080ea0d9
5 changed files with 116 additions and 17 deletions
|
|
@ -629,29 +629,74 @@ sub notifySubscribers {
|
|||
my $self = shift;
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
my $var = $self->getTemplateVars();
|
||||
$self->getThread->getParent->appendTemplateLabels($var);
|
||||
$var->{url} = $self->session->url->getSiteURL().$self->getUrl;
|
||||
my $thread = $self->getThread;
|
||||
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");
|
||||
my $message = $self->processTemplate($var, $self->getThread->getParent->get("notificationTemplateId"));
|
||||
my $unsubscribe = '<p><a href="'.$self->getThread->getParent->getUnsubscribeUrl.'">'.$i18n->get("unsubscribe","Asset_Collaboration").'</a></p>';
|
||||
my $from = $self->getThread->getParent->get("mailAddress");
|
||||
my $subject = $self->getThread->getParent->get("mailPrefix").$self->get("title");
|
||||
my $message = $self->processTemplate($var, $cs->get("notificationTemplateId"));
|
||||
my $unsubscribe = '<p><a href="'.$siteurl.$cs->getUnsubscribeUrl.'">'.$i18n->get("unsubscribe","Asset_Collaboration").'</a></p>';
|
||||
my $user = WebGUI::User->new($self->session, $self->get("ownerUserId"));
|
||||
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, {
|
||||
from=>$from,
|
||||
toGroup=>$self->getThread->getParent->get("subscriptionGroupId"),
|
||||
from=>"<".$from.">",
|
||||
replyTo=>"<".$replyTo.">",
|
||||
toGroup=>$cs->get("subscriptionGroupId"),
|
||||
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->addFooter;
|
||||
$mail->queue;
|
||||
my $mail = WebGUI::Mail::Send->create($self->session, {
|
||||
from=>$from,
|
||||
toGroup=>$self->getThread->get("subscriptionGroupId"),
|
||||
from=>"<".$from.">",
|
||||
replyTo=>"<".$replyTo.">",
|
||||
toGroup=>$thread->get("subscriptionGroupId"),
|
||||
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->addFooter;
|
||||
$mail->queue;
|
||||
|
|
|
|||
|
|
@ -157,12 +157,12 @@ sub format {
|
|||
$content =~ s/&/&/g;
|
||||
$content =~ s/\</</g;
|
||||
$content =~ s/\>/>/g;
|
||||
$content =~ s/\n/\<br \/\>/g;
|
||||
$content =~ s/\n/\<br \/\>\n/g;
|
||||
$content =~ s/\t/ /g;
|
||||
}
|
||||
if ($contentType eq "mixed") {
|
||||
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") {
|
||||
$content =~ s/ / /g;
|
||||
|
|
|
|||
|
|
@ -94,6 +94,30 @@ sub addFooter {
|
|||
$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 )
|
||||
|
|
@ -219,7 +243,7 @@ sub create {
|
|||
my $from = $headers->{from} || $session->setting->get("companyEmail");
|
||||
my $type = $headers->{contentType} || "multipart/mixed";
|
||||
my $domain = $from;
|
||||
$domain =~ s/\@(.*)/$1/;
|
||||
$domain =~ s/.*\@(.*)/$1/;
|
||||
my $id = $headers->{messageId} || "WebGUI-".$session->id->generate;
|
||||
unless ($id =~ m/\@/) {
|
||||
$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 )
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use base 'WebGUI::Workflow::Activity';
|
|||
use WebGUI::Mail::Get;
|
||||
use WebGUI::Mail::Send;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::HTML;
|
||||
use WebGUI::International;
|
||||
use WebGUI::User;
|
||||
|
||||
|
|
@ -78,7 +79,7 @@ sub addPost {
|
|||
if (($part->{type} =~ /^text\/plain/ || $part->{type} =~ /^text\/html/) && $part->{filename} eq "") {
|
||||
my $text = $part->{content};
|
||||
if ($part->{type} eq "text/plain") {
|
||||
$text =~ s/\n/\<br \/\>/g;
|
||||
$text = WebGUI::HTML::format($text, "text");
|
||||
}
|
||||
$content .= $text;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue