Show DevBest [PHP][OOP] Mailer/Bomber

Status
Not open for further replies.

Quackster

a devbest user says what
Aug 22, 2010
1,764
1,241
Hello.

Became bored so I coded a little mail bomber/sender. It needs to run on a web host with a SMTP server this to work.

But beware, if you put utter garbage from the 'from email part' or using illegitimate emails, it will think the email being sent is spam.


PHP:
<?php

########################
## Mailer by Quackster #
########################

class Mail
{
	private $to;
	private $from;
	private $subject;
	private $message;
	private $amount;

	public function beginMail($to, $from, $subject, $message, $amount)
	{
		$this->to = $to;
		$this->from = $from;
		$this->subject = $subject;
		$this->message = $message;
		$this->amount = $amount;
	}
	public function mailPage()
	{
		echo "<title>Mailer by Quackster</title>\r\n";
		echo "<body>\r\n";
		echo "<form method='post'>\r\n";
		echo "<input name='to' placeholder='Sending to..' type='text' /><br>";
		echo "<input name='from' placeholder='Sending from..' type='text' /><br>";
		echo "<input name='subject' placeholder='Subject..' type='text' /><br>";
		echo "<input name='amount' placeholder='Amount of mail' type='text' /><br>";
		echo "<textarea name='message' placeholder='Your message' style='width: 276px; height: 96px'></textarea><br>";
		echo "<input name='submit' value='Send mail!' type='submit' /><br>";
		echo "</form>\r\n";
		echo "</body>\r\n";
	}
	public function sendMail()
	{
 		$headers = "From: " . $this->from . "\r\n" . "X-Mailer: php";

 		$i = 0;

 		while ($i != $this->amount)
 		{
	 		if (mail($this->to, $this->subject, $this->message, $headers)) 
	 		{
	 			$i++;

	 			echo "Message sent.<br>";
			}
			else
			{
				echo "Message failed.<br>";
			}
		}
	}
}

$Mail = new Mail();

if (!isset($_POST["to"]))
{
	$Mail->MailPage();
}
else
{
	$Mail->beginMail($_POST['to'], $_POST['from'], $_POST['subject'], $_POST['message'], $_POST['amount']);
	$Mail->sendMail();
}
?>

[/code]
 
Status
Not open for further replies.

Users who are viewing this thread

Top