Productos > Técnicos de sistemas > Pasarela SMS > Pasarela SMS/SMTP > JAVA
JAVA
El siguiente ejemplo de código JAVA le permite enviar sus peticiones SMS por SMTP para poder utilizar nuestros servicios de mensajería SMS
import javax.mail.*; import javax.mail.internet.*; import java.util.*; public class MailTest { public static void main(String[] args) { // Dirección de envío del cliente, acordada con InfoAvisos String from = "ejemplo@cliente.com"; // Destinatario: teléfono 611223344 String recipient = "611223344@sms.infoavisos.com"; // Mensaje que se enviará String message = "Esto es una prueba de SMS"; String subject = ""; System.out.print("Enviando... "); try { boolean debug = false; // Servidor del cliente Properties props = new Properties(); props.put("mail.smtp.host", "10.11.12.13"); // create some properties and get the default Session Session session = Session.getDefaultInstance(props, null); session.setDebug(debug); // 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[1]; addressTo[0] = new InternetAddress(recipient); msg.setRecipients(Message.RecipientType.TO, addressTo); // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/plain"); Transport.send(msg); System.out.println("Hecho"); } catch (Exception e) { System.out.println("Error"); System.out.println(e); } } }
descargar ejemplo Pasarela SMS en JAVA
Pídenos más información:
Nombre y apellidos Empresa E-mail Teléfono ¿Cómo nos has conocido? (Opcional) Mensaje