30 lines
		
	
	
		
			1021 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			1021 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/php
 | |
| <?php
 | |
| require __DIR__.'/../vendor/autoload.php';
 | |
| 
 | |
| use nulib\app\cli\Application;
 | |
| use nulib\mail\mailer;
 | |
| use nulib\ValueException;
 | |
| 
 | |
| Application::run(new class extends Application {
 | |
|   const ARGS = [
 | |
|     "usage" => "SUBJECT BODY -t RECIPIENT",
 | |
|     "merge" => parent::ARGS,
 | |
|     ["-F", "--from", "args" => 1, "name" => "from", "argsdesc" => "MAILFROM"],
 | |
|     ["-t", "--to", "args" => 1, "action" => "--add", "name" => "to", "argsdesc" => "RECIPIENT"],
 | |
|     ["-c", "--cc", "args" => 1, "action" => "--add", "name" => "cc", "argsdesc" => "RECIPIENT"],
 | |
|     ["-b", "--bcc", "args" => 1, "action" => "--add", "name" => "bcc", "argsdesc" => "RECIPIENT"],
 | |
|     ["args" => 2, "name" => "args"],
 | |
|   ];
 | |
| 
 | |
|   protected $to, $cc, $bcc, $from;
 | |
| 
 | |
|   function main() {
 | |
|     $subject = $this->args[0] ?? null;
 | |
|     ValueException::check_null($subject, "subject");
 | |
|     $body = $this->args[1] ?? null;
 | |
|     ValueException::check_null($body, "body");
 | |
|     mailer::send($this->to, $subject, $body, $this->cc, $this->bcc, $this->from);
 | |
|   }
 | |
| });
 |