The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sending email to customers from command line

Discussion in 'E-mail Discussions' started by Datacenter1.com, Jun 30, 2009.

  1. Datacenter1.com

    Joined:
    Oct 28, 2005
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    /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 ;))
     
  2. PlatinumServerM

    PlatinumServerM Well-Known Member
    PartnerNOC

    Joined:
    Jul 10, 2005
    Messages:
    397
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    New Jersey, USA
    cPanel Access Level:
    Root Administrator
    You can use a simple mail routine in either perl or php.

    <?php
    $to = "someone@example.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@example.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    ?>
     
  3. Datacenter1.com

    Joined:
    Oct 28, 2005
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    /local/bar
    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
     
Loading...

Share This Page