MailSender.java
Dosyayı İndir
package com.godoro.samples.net;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.util.*;
public class MailSender {
public static void main(String[] args)
throws MessagingException
{
String server="mail.godoro.com";
String user="mailing@godoro.com";
String password="javaci";
Properties properties=System.getProperties();
//properties.put("mail.smtp.host", "mail.godoro.com");
Session session=Session.getDefaultInstance(properties);
Message message=new MimeMessage(session);
InternetAddress from=new InternetAddress("mailing@godoro.com");
message.setFrom(from);
InternetAddress to=new InternetAddress("on_der_tek_er@yahoo.com");
message.setRecipient(Message.RecipientType.TO,to);
message.setSubject("Message Subject 3");
//message.setText("Message Body");
Multipart multipart=new MimeMultipart();
MimeBodyPart text=new MimeBodyPart();
text.setText("Body Text");
multipart.addBodyPart(text);
String filename="C:\\Godoro\\Publishing\\JavaDeeply\\Book\\Resim.jpg";
MimeBodyPart attachment=new MimeBodyPart();
FileDataSource file = new FileDataSource(filename);
DataHandler handler=new DataHandler(file);
attachment.setDataHandler(handler);
attachment.setFileName("Resim.jpg");
multipart.addBodyPart(attachment);
message.setContent(multipart);
//Transport.send(message);
Transport transport=session.getTransport("smtp");
transport.connect(server,user,password);
transport.sendMessage(message,message.getAllRecipients());
}
}
Dosyayı İndir