Commit 21276f9d authored by Nigel Kukard's avatar Nigel Kukard

Merge branch 'nkupdates' into 'master'

Pulled in latest development changes

See merge request !23
parents d98f0e6e 733c171f
Pipeline #482 passed with stages
in 52 seconds
......@@ -1230,13 +1230,6 @@ sub sendInvoice
my $emailAddy = $1;
$emailAddy = $billEmailAddr if (!defined($emailAddy));
# Verify SMTP server is set
my $server = $config->{'mail'}{'server'};
if (!defined($server) || $server eq "") {
setError("Cannot use invoice emailing if we do not have an SMTP server defined");
return ERR_SRVPARAM;
}
# Check if we have a email addy
if ($emailAddy eq "") {
setError("No email address defined to send client invoice '".$invoice->{'Number'}."' to");
......@@ -1298,6 +1291,7 @@ sub sendInvoice
From => $config->{'invoicing'}{'email_from'},
To => $emailAddy,
Bcc => $config->{'invoicing'}{'email_bcc'},
'Reply-To' => $config->{'invoicing'}{'email_reply_to'},
Subject => "Invoice: ".$invoice->{'Number'},
Type => 'multipart/mixed'
);
......@@ -1331,10 +1325,19 @@ sub sendInvoice
}
# Send email
my @SMTPParams;
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send invoice via email server '$server'");
return ERR_SRVEXEC;
my $server = $config->{'mail'}{'server'};
if (defined($server) && $server ne "") {
# Send email via SMTP
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send invoice via email server '$server'");
return ERR_SRVEXEC;
}
} else {
# Send email via Sendmail
if (!(my $res = $msg->send("sendmail"))) {
setError("Failed to send invoice via sendmail");
return ERR_SRVEXEC;
}
}
} else {
......
......@@ -1251,13 +1251,6 @@ sub sendReceipt
# Pull email addr
my $emailAddy = $1 ne "" ? $1 : $billEmailAddr;
# Verify SMTP server is set
my $server = $config->{'mail'}{'server'};
if (!defined($server) || $server eq "") {
setError("Cannot use receipt emailing if we do not have an SMTP server defined");
return ERR_SRVPARAM;
}
# Check if we have a email addy
if ($emailAddy eq "") {
setError("No email address defined to send receipt '".$receipt->{'Number'}."' to");
......@@ -1319,6 +1312,7 @@ sub sendReceipt
From => $config->{'receipting'}{'email_from'},
To => $emailAddy,
Bcc => $config->{'receipting'}{'email_bcc'},
'Reply-To' => $config->{'receipting'}{'email_reply_to'},
Subject => "Receipt: ".$receipt->{'Number'},
Type => 'multipart/mixed'
);
......@@ -1352,11 +1346,19 @@ sub sendReceipt
}
# Send email
my @SMTPParams;
$res = $msg->send("smtp",$server);
if (!$res) {
setError("Failed to send receipt via email server '$server'");
return ERR_SRVEXEC;
my $server = $config->{'mail'}{'server'};
if (defined($server) && $server ne "") {
# Send email via SMTP
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send receipt via email server '$server'");
return ERR_SRVEXEC;
}
} else {
# Send email via Sendmail
if (!(my $res = $msg->send("sendmail"))) {
setError("Failed to send receipt via sendmail");
return ERR_SRVEXEC;
}
}
} else {
......
......@@ -891,18 +891,6 @@ sub sendReport
# Pull in email address user specified
my $emailAddy = $1;
# Verify SMTP server is set
my $server = $config->{'mail'}{'server'};
if (!defined($server) || $server eq "") {
if (!$background) {
setError("Cannot use report emailing if we do not have an SMTP server defined");
return ERR_SRVPARAM;
} else {
wiaflos::server::core::jobs::setStatus("Cannot use report emailing if we do not have an SMTP server defined");
exit 0;
}
}
# Check if we have a email addy
if (!defined($emailAddy) || $emailAddy eq "") {
if (!$background) {
......@@ -1024,14 +1012,28 @@ sub sendReport
wiaflos::server::core::jobs::setStatus("Sending mail...");
# Send email
my @SMTPParams;
if (!(my $res = $msg->send("smtp",$server))) {
if (!$background) {
setError("Failed to send report via email server '$server'");
return ERR_SRVEXEC;
} else {
wiaflos::server::core::jobs::setStatus("Failed to send report via email server '$server'");
exit 0;
my $server = $config->{'mail'}{'server'};
if (defined($server) && $server ne "") {
# Send email via SMTP
if (!(my $res = $msg->send("smtp",$server))) {
if (!$background) {
setError("Failed to send report via email server '$server'");
return ERR_SRVEXEC;
} else {
wiaflos::server::core::jobs::setStatus("Failed to send report via email server '$server'");
exit 0;
}
}
} else {
# Send email via Sendmail
if (!(my $res = $msg->send("sendmail"))) {
if (!$background) {
setError("Failed to send report via sendmail");
return ERR_SRVEXEC;
} else {
wiaflos::server::core::jobs::setStatus("Failed to send report via email server sendmail");
exit 0;
}
}
}
......
......@@ -290,13 +290,6 @@ sub sendStatement
# Pull email address user specified if its defined and not blank, or use billing email address
my $emailAddy = (defined($1) && $1 ne "") ? $1 : $billEmailAddr;
# Verify SMTP server is set
my $server = $config->{'mail'}{'server'};
if (!defined($server) || $server eq "") {
setError("Cannot use statement emailing if we do not have an SMTP server defined");
return ERR_SRVPARAM;
}
# Check if we have a email addy
if ($emailAddy eq "") {
setError("No email address defined to send statement to");
......@@ -359,6 +352,7 @@ sub sendStatement
From => $config->{'statements'}{'email_from'},
To => $emailAddy,
Bcc => $config->{'statements'}{'email_bcc'},
'Reply-To' => $config->{'statements'}{'email_reply_to'},
Subject => $subject,
Type => 'multipart/mixed'
);
......@@ -392,10 +386,19 @@ sub sendStatement
}
# Send email
my @SMTPParams;
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send statement via email server '$server'");
return ERR_SRVEXEC;
my $server = $config->{'mail'}{'server'};
if (defined($server) && $server ne "") {
# Send email via SMTP
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send statement via email server '$server'");
return ERR_SRVEXEC;
}
} else {
# Send email via Sendmail
if (!(my $res = $msg->send("sendmail"))) {
setError("Failed to send statement via sendmail");
return ERR_SRVEXEC;
}
}
} else {
......
......@@ -1075,13 +1075,6 @@ sub sendSupplierReceipt
# Pull email addr
my $emailAddy = $1 ne "" ? $1 : $billEmailAddr;
# Verify SMTP server is set
my $server = $config->{'mail'}{'server'};
if (!defined($server) || $server eq "") {
setError("Cannot use supplier receipt emailing if we do not have an SMTP server defined");
return ERR_SRVPARAM;
}
# Check if we have a email addy
if ($emailAddy eq "") {
setError("No email address defined to send supplier receipt '".$receipt->{'Number'}."' to");
......@@ -1144,6 +1137,7 @@ sub sendSupplierReceipt
From => $config->{'supplierreceipting'}{'email_from'},
To => $emailAddy,
Bcc => $config->{'supplierreceipting'}{'email_bcc'},
'Reply-To' => $config->{'supplierreceipting'}{'email_reply_to'},
Subject => "Receipt: ".$receipt->{'Number'},
Type => 'multipart/mixed'
);
......@@ -1177,10 +1171,19 @@ sub sendSupplierReceipt
}
# Send email
my @SMTPParams;
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send supplier receipt via email server '$server'");
return ERR_SRVEXEC;
my $server = $config->{'mail'}{'server'};
if (defined($server) && $server ne "") {
# Send email via SMTP
if (!(my $res = $msg->send("smtp",$server))) {
setError("Failed to send supplier receipt via email server '$server'");
return ERR_SRVEXEC;
}
} else {
# Send email via Sendmail
if (!(my $res = $msg->send("sendmail"))) {
setError("Failed to send supplier receipt via sendmail");
return ERR_SRVEXEC;
}
}
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment