Sending email to customers from command line

Oct 28, 2005
11
0
151
/local/bar
Hi,

I'm writing a little script to automatic suspend resource abusers (cpu, mysql & memory) but I want to sent an email to the customer when the account is suspended, how can I do that?

Is there a way to sent an email from command line to user X (X is a cpanel account off course ;))
 

PlatinumServerM

Well-Known Member
PartnerNOC
Jul 10, 2005
400
3
168
New Jersey, USA
cPanel Access Level
Root Administrator
You can use a simple mail routine in either perl or php.

<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
 
Oct 28, 2005
11
0
151
/local/bar
You can use a simple mail routine in either perl or php.

<?php
$to = "[email protected]";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
Thank you PlatinumServerM, I already know that

My question is how to sent an email from command line, when the only thing I have is the customer's username, or in other words, how can I get the user's email address from his username?

Thank You