Skip to content

Instantly share code, notes, and snippets.

@vijaykiran
Created August 4, 2011 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaykiran/1124888 to your computer and use it in GitHub Desktop.
Save vijaykiran/1124888 to your computer and use it in GitHub Desktop.
package controllers;
import org.apache.commons.mail.*;
import play.*;
import play.mvc.*;
import play.libs.*;
import java.util.*;
import models.*;
public class Application extends Controller {
public static void index() {
render();
}
public static void sendMail() throws Exception{
EmailAttachment attachment = new EmailAttachment();
attachment.setPath("PATH_TO_FILE");
attachment.setDisposition(EmailAttachment.ATTACHMENT);
attachment.setDescription("Picture of John");
attachment.setName("John");
// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("The picture");
email.setMsg("Here is the picture you wanted");
// add the attachment
email.attach(attachment);
Mail.send(email);
render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment