Receive MMS Messages Using Java


    This guide shows how to receive MMS messages on a Plivo phone number.

    You can start receiving MMS messages either by using our PHLO visual workflow builder or our APIs. Follow the instructions in one of the tabs below.

    To receive incoming MMS, you can create and deploy a PHLO with a few clicks on the PHLO canvas. PHLO also lets you visually construct your entire use-case. With PHLO, you only pay for MMS you send/receive, and building with PHLO is free. You can refer to the below instructions in the Using PHLO tab to begin your implementation.


    Receive MMS


    In this section, we will guide you to create a PHLO to Receive MMS.


    1. Create a Plivo Account(if you don’t have one already): You can sign up with your work email address and complete the phone verification step using your mobile number.
    2. Plivo Phone Number(Optional): To receive MMS, you must have a Plivo phone number that supports MMS. Numbers can be purchased from the Numbers section of your Plivo Console and use the same as the source number/from number for the outbound MMS. This number will also help you receive incoming MMS as you must have a MMS-enabled Plivo phone number to do the same. Please note that you can also purchase numbers using the Numbers API.

    Create the PHLO

    You can create a PHLO by referring to the below instructions to Receive MMS:

    Create a PHLO to receive SMS

    • On the side navigation bar, click PHLO. The PHLO page will appear and display your existing PHLOs, if any exist. If this is your first PHLO, then the PHLO page will be empty.
    • Click Create New PHLO to build a new PHLO.
    • In the Choose your use-case window, click Build my own. The PHLO canvas will appear with the Start node.
      Note: The Start node is the starting point of any PHLO. You can choose between the four available trigger states of the start node; Incoming SMS, Incoming Call, and API Request. For this PHLO, we will use the Incoming Message trigger state.
    • From the list of components on the left-hand side, drag and drop the HTTP Request component onto the canvas. This will add a HTTP Request node onto the canvas.
    • Connect the Start node with the HTTP Request node, using the Incoming Message trigger state.
    • Configure the HTTP Request node to send the details to your Web Server.
    • Once you have configured the node, click Validate to save the configurations.
    • After you complete the configurations, provide a recognizable name for your PHLO and click Save. Your PHLO is now ready.

    Assign the PHLO to a Plivo Number for Incoming MMS

    Once you have created and configured your PHLO, assign your PHLO to a Plivo number.

    To assign a PHLO to a number

    1. Log in to your Plivo Console
    2. On the Product Navigation bar, click Phone Numbers.
    3. On the Numbers page, under Your Numbers, click the phone number you wish to use for the PHLO.
    4. In the Number Configuration window, select PHLO from the Application Type list.
    5. From the PHLO Name list, select the PHLO you wish to use with the phone number, and then click Update Number.

    Assign PHLO to a Plivo Number

    If you have not purchased a phone number yet, you can buy a phone number(s) by referring to the instructions available here.

    Test and Validate

    You can now receive a message to your Plivo phone number to receive an incoming MMS and see how the inbound MMS is handled using PHLO.

    For more information about creating a PHLO app, see the PHLO User Guide.
    For information on components and their variables, see the PHLO Components Library.

    To receive your first incoming MMS, you can refer to the instructions in the following section to begin your implementation.


    Receive MMS


    In this section, we will guide you in setting up an app to receive a MMS on your Plivo number.


    1. Plivo account: Sign up for a Plivo account if you don’t have one already.
    2. Plivo phone number:: To receive MMS, you must have a Plivo phone number that supports MMS. You can purchase numbers from the Numbers page of the Plivo console or by using the Numbers API.

    Buy a New Plivo Number

    Install Java, Spring and the Plivo Java package

    You must set up and install Java(Java 1.8 or higher) and Plivo’s Java SDK to Receive Incoming MMS. Here’s how.

    Install Java

    Operating SystemInstructions
    macOS & LinuxTo see if you already have Java installed, run the command java -version in the terminal. If you do not have it installed, you can install it from here.
    WindowsTo install Java on Windows follow the instructions listed here.

    Install Spring and Plivo Java Package using IntelliJ Idea

    • Use Spring Initializr to create a boilerplate project with Spring Boot framework.

      Create Boilerplate code

    • Choose the “Spring Web” dependency, Give the project a friendly name and click “Generate” to download the boilerplate code and open it in IntelliJ Idea.

      Boilerplate project in IntelliJ

      Note: Please set the Java target as 11.
    • Install the Plivo Java package by adding the dependency in pom.xml


      Install Plivo package

    Create a Spring Webapp to Receive Incoming MMS

    Now, import the downloaded folder from Spring Initializr & open the file PlivoSmsApplication and paste the below code

    package com.example.Plivo.SMS;
    import com.plivo.api.exceptions.PlivoXmlException;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.GetMapping;
    import org.springframework.web.bind.annotation.RestController;
    public class PlivoSmsApplication {
    	public static void main(String[] args) {, args);
    	@GetMapping(value = "/reply_mms/")
    	public String getBody(String From, String To, String Text, String media_url) throws PlivoXmlException {
    		System.out.println(From + " " + To + " " + Text+ " " + media_url);
    		return "message received";

    Run the project and you should see your basic server app in action on http://localhost:4567/receive_mms/

    Exposing your local server to the internet

    To receive mms incoming messages and to handle callbacks, your local server should be able to connect with Plivo API service, Ngrok is a tunneling software used to expose a web server running on your local machine to the internet. Using Ngrok you can set webhooks which can talk to Plivo server.

    ngrok block diagram

    Install ngrok and run it on the command line, specifying the port that hosts the application on which you want to receive messages (8080 in this case):

    $ ./ngrok http 8080

    Ngrok will display a forwarding link that you can use as a webhook to access your local server over the public network.

    Sample ngrok CLI

    In this case, the ngrok url will be something like

    Create an Application

    1. Create an Application by visiting the Application Page and click on New Application. You can also use Plivo’s Application API.
    2. Give your application a name. Let’s call it Receive MMS. Enter your server URL (e.g. in the Message URL field and set the method as GET. See our Application API docs to learn how to modify your application through our APIs.
    3. Click on Create Application to save your application.

    Create Application

    Assign a Plivo number to your app

    1. Navigate to the Numbers page and select the phone number you want to use for this app.
    2. Select Receive MMS (name of the app) from the Plivo App dropdown list.
    3. Click on Update to save.

    Assign Phone Number to Receive MMS App

    Test and validate

    Receive MMS to your Plivo number using a regular mobile phone. Plivo will send a request to your Message URL with the parameters listed in the Messages Documentation.