Need help regarding sending SMS using java

╄→尐↘猪︶ㄣ 提交于 2019-12-08 02:47:16

问题


I want to send SMS using my java program. The scenario is that i have a server on which management program(written In java) is running. User can post their problems on the server. I want that when someone post their problem on server my java program generate an SMS to the user mobile number that your problem has been submitted. I searched Google and found that you can use Java Mail API to send sms to user. I tried the program given on this link

i used these parameters

......

public void msgSend() {

        String gmailUserName = "xxxx@gmail.com";
        String gmailPassword =  "xxxx";
        String smtpHost = "smtp.gmail.com";
        String compression = "My Sms Compression information";
        String from = "Basit@smtp.gmail.com";
        String to = "03072525725@sms.smtp.gmail.com";
        String body = "Hi how r u";
        Transport myTransport = null;
        ...
        ...

After using this i received an email on my Gmail account with the following error

Delivery to the following recipient failed permanently:

03072525725@sms.smtp.gmail.com

Technical details of permanent failure: DNS Error: Domain name not found

I think that perhaps i didn't configure my Gmail account for mobile that's why i got this error. But i want to ask is it possible that i send sms using Java Mail API?


回答1:


The error message shows you exactly the problem:

DNS Error: Domain name not found

There is no DNS entry for sms.smtp.google.com. It doesn't have anything to do with your settings. Google does not offer a public SMS gateway (sending SMS normally costs money).

You could try Amazon Simple Notification Service, for example.




回答2:


It is possible to use email to send messages via SMS using an SMS gateway. It does require you to know the recipient phone number's carrier however.

For example:

Using the chart in the Wikipedia article in the link above, if the phone number is 7675431234 and the carrier is AT&T, then the email address to use would be 7675431234@txt.att.net.



来源:https://stackoverflow.com/questions/8251037/need-help-regarding-sending-sms-using-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!