Re: [xmail] Email all local accounts?

2011-11-18 Thread Fred
Hi,

Thanks for your reply, here is what I have come up with if someone else is
interested.

#!/usr/local/bin/php
 $line)
{
$data = explode("\t", $line);
$accounts[] = substr($data[1], 1, -1) . "@" .
substr($data[0], 1, -1);
}
return $accounts;
}

function send_maintenance_mail($account)
{
$to = strtolower($account);
$from = "postmas...@yourdomain.com";
$current_date = date("Y-m-d G:i:s");
$subject = "Your subject";

$mime_boundary = "mail.yourdomain.com" . md5(time());

$headers = "From: postmas...@yourdomain.com
\n";
$headers .= "Reply-To: postmas...@yourdomain.com, " . $to . "\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"" .
$mime_boundary . "\"\n";

$message = "--" . $mime_boundary . "\n";
$message .= "Content-Type: text/html; charset=UTF-8\n";
$message .= "Content-Transfer-Encoding: 8bit\n\n";

$message .= "\n";
$message .= "\n";
$message .= "Your message. \n";
$message .= "\n";
$message .= "\n";

$message .= "--" . $mime_boundary . "--\n\n";

if(mail($to, $subject, $message, $headers))
{
return true;
}
else
{
return false;
}
}

$accounts = xmail_accounts_list("/mailsrv/MailRoot/mailusers.tab");

foreach ($accounts as $account_num => $account)
{
if(!send_maintenance_mail($account))
{
echo "Error sending mail to " . $account;
        exit;
        }
}

echo "Email sent to " . count($accounts) . " accounts.\n";

exit;

?>


From: xmail-boun...@xmailserver.org [mailto:xmail-boun...@xmailserver.org]
On Behalf Of Ivo Smits
Sent: 18 novembre 2011 11:07
To: xmail@xmailserver.org
Subject: Re: [xmail] Email all local accounts?

Hi,

I don't think this is directly supported. You can generate a list of e-mail
addresses from the mailusers file, for example using this command on linux:
cat mailusers.tab | sed -n 's/^"\([^"]*\)"\t"\([^"]*\)"\t.*$/\2@\1/p'

You could write the output to a file and pass it to sendmail using the
--rcpt-file option.

--
Ivo

Op 18-11-2011 16:37, Fred schreef: 
Hey guys,
 
Quick question; is there a way to broadcast an email to all XMail accounts
on a  single server?
 
I need to inform everyone, about 800 accounts, that I will do hardware
maintenance this week-end.
 
Thanks 
 
 



___
xmail mailing list
xmail@xmailserver.org
http://xmailserver.org/mailman/listinfo/xmail

___
xmail mailing list
xmail@xmailserver.org
http://xmailserver.org/mailman/listinfo/xmail


Re: [xmail] Email all local accounts?

2011-11-18 Thread Ivo Smits

Hi,

I don't think this is directly supported. You can generate a list of 
e-mail addresses from the mailusers file, for example using this command 
on linux:

cat mailusers.tab | sed -n 's/^"\([^"]*\)"\t"\([^"]*\)"\t.*$/\2@\1/p'

You could write the output to a file and pass it to sendmail using the 
--rcpt-file option.


--
Ivo

Op 18-11-2011 16:37, Fred schreef:


Hey guys,

Quick question; is there a way to broadcast an email to all XMail 
accounts on a  single server?


I need to inform everyone, about 800 accounts, that I will do hardware 
maintenance this week-end.


Thanks



___
xmail mailing list
xmail@xmailserver.org
http://xmailserver.org/mailman/listinfo/xmail
___
xmail mailing list
xmail@xmailserver.org
http://xmailserver.org/mailman/listinfo/xmail