Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- */
- import java.io.*;
- import java.net.InetAddress;
- import java.util.Properties;
- import java.util.Date;
- import javax.mail.*;
- import javax.mail.internet.*;
- import com.sun.mail.smtp.*;
- public class Distribution {
- public static void main(String args[]) throws Exception {
- Properties props = System.getProperties();
- props.put("mail.smtps.host","smtp.gmail.com");
- props.put("mail.smtps.auth","true");
- Session session = Session.getInstance(props, null);
- Message msg = new MimeMessage(session);
- msg.setFrom(new InternetAddress("[email protected]"));;
- msg.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse("[email protected]", false));
- msg.setSubject("Heisann "+System.currentTimeMillis());
- msg.setText("Med vennlig hilsennTov Are Jacobsen");
- msg.setHeader("X-Mailer", "Tov Are's program");
- msg.setSentDate(new Date());
- SMTPTransport t =
- (SMTPTransport)session.getTransport("smtps");
- t.connect("smtp.gmail.com", "[email protected]", "<insert password here>");
- t.sendMessage(msg, msg.getAllRecipients());
- System.out.println("Response: " + t.getLastServerResponse());
- t.close();
- }
- }
- MailQue.queMail(MimeMessage message)
- //Set the host smtp address
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.jcom.net");
- // create some properties and get the default Session
- Session session = Session.getDefaultInstance(props,
- // create a message
- Message msg = new MimeMessage(session);
- // set the from and to address
- InternetAddress addressFrom = new InternetAddress(from);
- msg.setFrom(addressFrom);
- InternetAddress[] addressTo = new InternetAddress[recipients.length];
- for (int i = 0; i < recipients.length; i++)
- {
- addressTo[i] = new InternetAddress(recipients[i]);
- }
- msg.setRecipients(Message.RecipientType.TO,
- // Optional : You can also set your custom headers in the Email if
- // Setting the Subject and Content Type
- msg.setSubject(subject);
- msg.setContent(message, "text/plain");
- Transport.send(msg); }
Add Comment
Please, Sign In to add comment