Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Flock\Console\Command;
- use Symfony\Component\Config\Definition\Exception\Exception;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- use Symfony\Component\Templating\Loader\FilesystemLoader;
- use Symfony\Component\Templating\PhpEngine;
- use Symfony\Component\Templating\TemplateNameParser;
- use Symfony\Component\Yaml\Yaml;
- class MailerCommand extends Command {
- /**
- * @var OutputInterface
- */
- private $output;
- /**
- * Configures the current command.
- */
- protected function configure()
- {
- $this
- ->setName('notification:mailer')
- ->setDescription('send an email to someone.')
- ->addArgument(
- 'email',
- InputArgument::REQUIRED,
- 'What is the e-mail address of the receiver?'
- )
- ->addArgument(
- 'body',
- InputArgument::REQUIRED,
- 'Information about the machine and dataset in which the experiment was running.'
- )
- ->addArgument(
- 'subject',
- InputArgument::OPTIONAL,
- 'What is the subject of the conversation?'
- );
- }
- /**
- * Executes the current command.
- *
- * This method is not abstract because you can use this class
- * as a concrete class. In this case, instead of defining the
- * execute() method, you set the code to execute by passing
- * a Closure to the setCode() method.
- *
- * @param InputInterface $input An InputInterface instance
- * @param OutputInterface $output An OutputInterface instance
- *
- * @return null|int null or 0 if everything went fine, or an error code
- *
- * @throws \LogicException When this abstract method is not implemented
- *
- * @see setCode()
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $email = $input->getArgument('email');
- $subject = $input->getArgument('subject') ? $input->getArgument('subject') : "Sent by flock-mailer";
- $body = $input->getArgument('body');
- $this->output = $output;
- $mailer = new \PHPMailer;
- $this->configureMailer($mailer);
- $this->sendMail($mailer, $email, $subject, $body);
- }
- /**
- * @param $mailer \PHPMailer
- */
- private function configureMailer($mailer)
- {
- $configFile = ROOT . '/config/email.yml';
- $configValues = [];
- try {
- $configValues = Yaml::parse($configFile);
- } catch (Exception $e) {
- $this->output->writeln("There was a error while parsing the configuration file. Check the error below:");
- $this->output->writeln($e->getMessage());
- exit(1);
- }
- if (!empty($configValues)) {
- $mailer->isSMTP(); // Set mailer to use SMTP
- $mailer->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mailer->Port = 587; // TCP port to connect to
- $mailer->SMTPAuth = true; // Enable SMTP authentication
- $mailer->Username = $configValues['from']; // SMTP username
- $mailer->Password = $configValues['passwd']; // SMTP password
- $mailer->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mailer->setFrom($configValues['from'], $configValues['name']);
- if ($configValues['debug'] && $configValues['debug'] > 0) {
- $mailer->SMTPDebug = 2;
- $mailer->Debugoutput = 'html';
- }
- }
- }
- /**
- * @param $mailer \PHPMailer
- * @param $to string
- * @param $subject string
- * @param $body string
- */
- private function sendMail($mailer, $to, $subject, $body)
- {
- $addresses = $this->parseEmails($to);
- //$kontolers = $this->txtemail($to);
- if (is_array($addresses)) {
- foreach ($addresses as $address) {
- $mailer->addAddress($address);
- }
- } else {
- $mailer->addAddress($to);
- }
- $mailer->Subject = $subject;
- $loader = new FilesystemLoader(ROOT . '/src/Flock/Templates/%name%');
- $templating = new PhpEngine(new TemplateNameParser(), $loader);
- $mailer->msgHTML($templating->render('message.php', array('custom' => $body)));
- if ( $mailer->send() ) {
- echo "[".date("H:i:s")."] Finished for sending : {$to}\n";
- } else {
- echo "The message could not be delivered.";
- echo "Mailer error: " . $mailer->ErrorInfo;
- }
- }
- /**
- * Parse the email passed to see if is multiple email.
- * @param $to string String with multiple emails or not.
- * @return array|string If the email contains string return an array with all the emails
- * passed as parameter, return the $to parameter itself otherwise.
- */
- /*private function parseEmails($to)
- {
- if (strpos($to, ",") !== false) {
- return explode(',', $to);
- }
- return $to;
- }
- }*/
- $Logo = "
- ___. __ ________
- /$$$$$$$ /$$ /$$ /$$ /$$
- | $$__ $$ | $$ | $$ | $$ | $$
- | $$ \ $$/$$ /$| $$/$$ /$$ | $$ | $$ /$$$$$$| $$/$$ /$$ /$$$$$$$
- | $$$$$$$| $$ | $| $| $$ | $$ | $$$$$$$$|____ $| $| $$ | $$/$$_____/
- | $$__ $| $$ | $| $| $$ | $$ | $$__ $$ /$$$$$$| $| $$ | $| $$$$$$
- | $$ \ $| $$ | $| $| $$ | $$ | $$ | $$/$$__ $| $| $$ | $$\____ $$
- | $$$$$$$| $$$$$$| $| $$$$$$/ | $$ | $| $$$$$$| $| $$$$$$//$$$$$$$/
- |_______/ \______/|__/\______/ |__/ |__/\_______|__/\______/|_______/
- -------------- Email Sender CLI - V1.0.0----------------------
- thanks to : Allah SWT . - Bejog , - pedro-stanaka, - Symfony, - PHPMailer
- ";
- //$kontolers = $this->txtemail($to);
- private function parseEmails ($to){
- if(isset($argv[1]) !== false){
- $get = file_get_contents($argv[1]) or die("\n[Warning] Mail List Gak Ada GBLK !!!\n");
- $listmail = explode("\r\n",$get);
- echo "\n[".date("H:i:s")."] Sending.. ".count($listmail)." email. Please wait ... \n";
- //foreach($listmail as $to){
- echo "[".date("H:i:s")."] Sending email to : {$to}\n";
- $f1 = fopen("latest-maillist.txt","w");
- fwrite($f1,$to."\r\n");
- fclose($f1);
- //$Exploiter->Dork($dork);
- //for($i=1;$i<18;$i++){
- //for($i=1;$i<17;$i++){
- //$kontolers->SearchEngine($i);
- }
- //echo "[".date("H:i:s")."] Finished for sending : {$to}\n";
- } else {
- echo $Logo."\n";
- echo "[=] Usage : php $argv[0] listdork.txt\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement