Sent a Mail (simplified)
in
Share your Work
•
2 years ago
I took a look at Daniel Shiffman's article about
Emails in Processing and a tried to make a simplified version of it. With this code you can receive emails with pop3 from Hotmail and Gmail and sent emails with smtp in Gmail. Unfortunately you can't do both in one sketch and you have to include pop3.jar in the sketch althouch it is included in the Java Mail API.
Receive emails (example):
Receive emails (example):
- PMailReceiver receiver;
- public void setup() {
- size(500, 500);
- receiver=new PMailReceiver(this,"pop.gmail.com", "YOURUSERNAME@gmail.com", "YOURPASSWORD");
- receiver.update();
- println(receiver.getMessageCount() + " total messages.");
- PMessage[] messages=receiver.getUnreadMessages();
- for (int i=0;i<messages.length;i++) {
- println("---------------------");
- println("Message # " + (i+1));
- println("From: " + messages[i].getFrom());
- println("Subject: " + messages[i].getSubject());
- println("Message:");
- println(messages[i].getMessage());
- }
- receiver.quit();
- }
- PMailSender sender;
- public void setup() {
size(500, 500); - sender=new PMailSender(this,"smtp.gmail.com", "YOURUSERNAME@gmail.com", "YOURPASSWORD");
- sender.setFrom("NAME@...", "NAME");
- sender.setTo("NAME@...");
- sender.update();
- sender.send("Hello World", "test");
- println("Email sent!");
- }
The code isn't very good and there are maybe errors when starting but maybe this two classes are helpful for somebody.
You can download the source and example from here
You can download the source and example from here