Commit 01c27679 authored by Stanislav German-Evtushenko's avatar Stanislav German-Evtushenko Committed by Dietmar Maurer

GUI: add new email_from option to datacenter.cfg

Signed-off-by: 's avatarStanislav German-Evtushenko <ginermail@gmail.com>
parent 1d095287
......@@ -341,10 +341,11 @@ __PACKAGE__->register_method({
if ($mailto) {
my $hostname = `hostname -f` || PVE::INotify::nodename();
chomp $hostname;
my $mailfrom = $dcconf->{email_from} || "root";
my $data = "Content-Type: text/plain;charset=\"UTF8\"\n";
$data .= "Content-Transfer-Encoding: 8bit\n";
$data .= "FROM: <root\@$hostname>\n";
$data .= "FROM: <$mailfrom>\n";
$data .= "TO: $mailto\n";
$data .= "SUBJECT: New software packages available ($hostname)\n";
$data .= "\n";
......@@ -364,7 +365,7 @@ __PACKAGE__->register_method({
return if !$count;
my $fh = IO::File->new("|sendmail -B 8BITMIME $mailto") ||
my $fh = IO::File->new("|sendmail -B 8BITMIME -f $mailfrom $mailto") ||
die "unable to open 'sendmail' - $!";
print $fh $data;
......
......@@ -279,8 +279,10 @@ my $sendmail = sub {
foreach my $r (@$mailto) {
$rcvrarg .= " '$r'";
}
my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg');
my $mailfrom = $dcconf->{email_from} || "root";
open (MAIL,"|sendmail -B 8BITMIME $rcvrarg") ||
open (MAIL,"|sendmail -B 8BITMIME -f $mailfrom $rcvrarg") ||
die "unable to open 'sendmail' - $!";
my $rcvrtxt = join (', ', @$mailto);
......@@ -289,7 +291,7 @@ my $sendmail = sub {
print MAIL "\tboundary=\"$boundary\"\n";
print MAIL "MIME-Version: 1.0\n";
print MAIL "FROM: vzdump backup tool <root>\n";
print MAIL "FROM: vzdump backup tool <$mailfrom>\n";
print MAIL "TO: $rcvrtxt\n";
print MAIL "SUBJECT: vzdump backup status ($hostname) : $stat\n";
print MAIL "\n";
......
......@@ -24,12 +24,15 @@ eval {
my $rootcfg = $usercfg->{users}->{'root@pam'} || {};
my $mailto = $rootcfg->{email};
my $dcconf = cfs_read_file('datacenter.cfg');
my $mailfrom = $dcconf->{email_from} || "root";
die "user 'root\@pam' does not have a email address\n" if !$mailto;
syslog("info", "forward mail to <$mailto>");
# we never send DSN (avoid mail loops)
open(CMD, "|sendmail -bm -N never $mailto") ||
open(CMD, "|sendmail -bm -N never -f $mailfrom $mailto") ||
die "can't exec sendmail - $!\n";
while (<>) { print CMD $_; }
close(CMD);
......
......@@ -74,11 +74,37 @@ Ext.define('PVE.dc.ConsoleViewerEdit', {
}
});
Ext.define('PVE.dc.EmailFromEdit', {
extend: 'PVE.window.Edit',
initComponent : function() {
var me = this;
Ext.applyIf(me, {
subject: gettext('Email from address'),
items: {
xtype: 'pvetextfield',
name: 'email_from',
vtype: 'email',
emptyText: gettext('Send emails from root@$hostname'),
deleteEmpty: true,
value: '',
fieldLabel: gettext('Email from address')
}
});
me.callParent();
me.load();
}
});
Ext.define('PVE.dc.OptionView', {
extend: 'PVE.grid.ObjectGrid',
alias: ['widget.pveDcOptionView'],
noProxyText: gettext('Do not use any proxy'),
noEmailFromText: gettext('Send emails from root@$hostname'),
initComponent : function() {
var me = this;
......@@ -110,6 +136,17 @@ Ext.define('PVE.dc.OptionView', {
editor: 'PVE.dc.ConsoleViewerEdit',
required: true,
renderer: PVE.Utils.render_console_viewer
},
email_from: {
header: gettext('Email from address'),
editor: 'PVE.dc.EmailFromEdit',
required: true,
renderer: function(value) {
if (!value) {
return me.noEmailFromText;
}
return value;
}
}
};
......
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