<?php

require_once __DIR__."/mail/mail_sender.php";
require_once __DIR__."/mail/mail_setting.php";
require_once __DIR__."/mail/chocomae_info.php";

if($argc != 4) {
	echo "check the input arguments\n";
	exit(0);
}

// for($i = 0; $i < $argc; $i++) {
// 	echo "[".$i."] : ".$argv[$i]."\n";
// }
// exit(0);


$maestroEmail = $argv[1];
$maestroName = $argv[2];
$date = $argv[3];
$year = substr($date, 0, 4);
$month = substr($date, 4, 2);
$day = substr($date, 6, 2);
$registerDate = $year."년 ".$month."월 ".$day."일";


$parameters = array(
    "maestro_name"	=> $maestroName,
    "register_date"	=> $registerDate,
);

$recipientParam = array(
	"maestro_name" => $maestroName
);


$nCloudSetting = new MailSetting();
$chocomae = new ChocomaeInfo();

$mailSender = new MailSender();
$mailSender->setMailSetting($nCloudSetting);
$mailSender->setSenderInfo($chocomae->sender_name, $chocomae->sender_email);

$mailSender->makePostParam(337);
$mailSender->setParameters($parameters);
$mailSender->addRecipient($maestroEmail, $maestroName, "R", $recipientParam);
$mailSender->addRecipient($chocomae->sender_bcc, $chocomae->sender_name, "B", $recipientParam);

// $mailSender->showSettings();
$mailSender->send();

?>
