But there must be some other problem...
I only need the capability to send mails, so I've deleted the checkMail() function from MailStuff module.
I've also comented out the lines
" println("Mail sent!");"
and
" //e.printStackTrace();"
in MailStuff.
But it will not send mails
Can you give me a hint how I can get the error message on the screen?
Regards,
Roland
Here is the complete code:
Module Email:
// Daniel Shiffman
// http://www.shiffman.net
// Simple E-mail Checking
// This code requires the Java mail library
// smtp.jar, pop3.jar, mailapi.jar, imap.jar, activation.jar
// Download:// http://java.sun.com/products/javamail/
import javax.mail.*;
import javax.mail.internet.*;
int success = 0;
void setup() {
PFont font = loadFont("ArialUnicodeMS-12.vlw");
textAlign(CENTER);
textFont(font);
// Function to send mail
sendMail();
size(200,200);
if (success == 0) {
text("Sent mail",100,40);
} else {
text("Error",100,40);
}
//exit();
noLoop();
}
Module Auth:
// Daniel Shiffman
// http://www.shiffman.net
// Simple Authenticator
// Careful, this is terribly unsecure!!
import javax.mail.Authenticator;
import javax.mail.PasswordAuthentication;
public class Auth extends Authenticator {
public Auth() {
super();
}
public PasswordAuthentication getPasswordAuthentication() {
String username, password;
username = "<USER>";
password = "<PASSWORD>";
//System.out.println("authenticating. . ");
return new PasswordAuthentication(username, password);
}
}
Module MailStuff:
// Daniel Shiffman
// http://www.shiffman.net
// Example functions that check mail (pop3) and send mail (smtp)
// You can also do imap, but that's not included he
// A function to send mail
void sendMail() {
// Create a session
String host="exchg02";
Properties props=new Properties();
// SMTP Session
props.put("mail.transport.protocol", "smtp");
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", "25");
props.put("mail.smtp.auth", "true");
// We need TTLS, which gmail requires
props.put("mail.smtp.starttls.enable","true");
// Create a session
Session session = Session.getDefaultInstance(props, new Auth());
try
{
// Make a new message
MimeMessage message = new MimeMessage(session);
// Who is this message from
message.setFrom(new InternetAddress("admin@domain.com", "Name"));
// Who is this message to (we could do fancier things like make a list or add CC's)
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("<Recipient@domain.com", false));
// Subject and body
message.setSubject("Processing ist prima");
message.setText("It's great to be here. . .");
// We can do more here, set the date, the headers, etc.
Transport.send(message);
//println("Mail sent!");
success = 0;
}
catch(Exception e)
{
//e.printStackTrace();
success = 1;
}
}