2010-06-30 2 views
0

임, 내가 자바를 사용하여 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 알림을 보내고 싶습니다. 자바에서도 가능합니까? 미리 감사드립니다.

+0

[Java에서 SMS를 보내는 방법은 무엇입니까?] (http://stackoverflow.com/questions/545441/how-can-i-send-an-sms-from-java) –

+0

다음을 시도해보십시오. http : //stackoverflow.com/search?q=[java]+sms –

답변

0

이미 많은 게시물이 이미 있습니다.

제 조언은 aspsms.com과 같은 제 3 자 제공 업체를 거쳐 API (웹 서비스 또는 wathever)를 사용하는 것입니다.

이 API에는 .Net API가 있지만 Java에서는 SOAP 웹 서비스를 사용할 수 있어야합니다.

1

이 작업을 쉽게 수행 할 수있는 방법은 SMS 수신함으로 이메일을 보내는 것입니다.

각 공급자마다 도메인이 다르지만 [mynumber] @ messaging.sprintpcs.com으로 전송 된 스프린트 이메일에 대한 내용이 나에게 전달됩니다.

많은 지연이있는 것처럼 보이지 않지만 오류 상태에서 전자 메일과 텍스트를이 방식으로 보내고 동시에 도착하는 프로세스를 모니터링합니다.

수신자가 여러 네트워크에 분산되어있는 경우 전자 메일 도메인을 조회해야하기 때문에 이런 종류의 시스템을 유지 관리하는 것이 까다로워집니다.

관련 문제