XMailforum is a readonly knowledge archive now.

Registering as a new user or answering posts is not possible anymore.

Might the force be with you, to find here what you are looking for.

2019-09-20 - hschneider, Admin

Cookie Disclaimer: This forum uses only essential, anonymous session cookies (xmailforum*), nothing to be scared of.

XMail Forum -> How To Send E-mail To All Users?

Reply to this topicStart new topicStart Poll

> How To Send E-mail To All Users?
impiouspunk
Posted: Mar 23 2009, 09:48 PM
Quote Post


Newbie
*

Group: Members
Posts: 20
Member No.: 1701
Joined: 3-August 05



Is there an easy way to send e-mail to all users? I know I could create a mailing list and add all users to it, but even that would be cumbersome.
PMEmail Poster
Top
BizOdd
Posted: Mar 25 2009, 07:42 PM
Quote Post


Member
***

Group: Members
Posts: 58
Member No.: 1386
Joined: 1-November 04



If you have PHP on your server,
you could try this script I wrote awhile ago,
should do the trick.

-BizOdd


CODE

#!/usr/bin/php
<?PHP
//
//Send an email to everyone on the system
//
$mailroot = "/var/MailRoot/";
$domainroot = $mailroot."domains";
$message = "\r\nThe system will be down for 5 minutes this evening at 6pm\r\n";
$subject = "System Down Time this evening";
$from = "Postmaster@Domain.Tld";
//
//
$grouplist = $mailroot."mailusers.tab";
$listline = @file($grouplist);
if ($listline != FALSE) {
foreach ($listline as $line){
 if (substr($line,0,1) == "#") continue;
 $data = explode("\t",$line);
 $domain = trim($data[0],"\x22\x27\r\n");
 $user = trim($data[1],"\x22\x27\r\n");
 $isdir = is_dir($domainroot."/".$domain."/".$user."/Maildir/new");
 $mailfile = $domainroot."/".$domain."/".$user."/Maildir/new/email_from_admin.txt";
 if ($isdir == true) {
  file_put_contents($mailfile,Mailcontents($from,$user,$domain,$subject,$message));
 }
}
}
 

function Mailcontents($from,$user,$domain,$subject,$message)
{
$return =  "Date: ".date(DATE_RFC822)."\r\n";
$return .= "From: $from\r\n";
$return .= "To: ".$user."@".$domain."\r\n";
$return .= "Subject: $subject\r\n";
$return .= "MIME-Version: 1.0\r\n";
$return .= "Content-Type: text/plain; charset=ISO-8859-1; format=flowed\r\n";
$return .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$return .= $message."\r\n\r\n";
return($return);
}
?>



PMEmail Poster
Top
impiouspunk
Posted: Mar 25 2009, 08:39 PM
Quote Post


Newbie
*

Group: Members
Posts: 20
Member No.: 1701
Joined: 3-August 05



Thanks a lot! This worked perfectly. Perhaps some one could make a sticky out of this for future reference. Or perhaps add to the Wiki.
PMEmail Poster
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:
« Next Oldest | XMail Server | Next Newest »

Reply to this topicStart new topicStart Poll