임, 내가 자바를 사용하여 SMSAlert 응용 프로그램을 개발할 할 java를 사용하여 모바일에 SMS 알림을 보내는 방법은 무엇입니까?
public class SendMail {
public SendMail() throws MessagingException {
String host = "smtp.gmail.com";
String Password = "mnmnn";
String from = "[email protected]";
String toAddress = "[email protected]";
String filename = "C:/Users/hp/Desktop/Write.txt";
// Get system properties
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
props.put("mail.smtps.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, toAddress);
message.setSubject("JavaMail Attachment");
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText("Here's the file");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filename);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
try {
Transport tr = session.getTransport("smtps");
tr.connect(host, from, Password);
tr.sendMessage(message, message.getAllRecipients());
System.out.println("Mail Sent Successfully");
tr.close();
} catch (SendFailedException sfe) {
System.out.println(sfe);
}
}
}`
code.`
을 다음과 같이 자바를 사용하여 이메일을 전송했을 간단한 이메일 응용 프로그램을 개발하고 있습니다. 메일을받을 때마다 내 번호로 SMS 알림을 보내고 싶습니다. 자바에서도 가능합니까? 미리 감사드립니다.
[Java에서 SMS를 보내는 방법은 무엇입니까?] (http://stackoverflow.com/questions/545441/how-can-i-send-an-sms-from-java) –
다음을 시도해보십시오. http : //stackoverflow.com/search?q=[java]+sms –