Blog
Java: Send SMS and Email Notifications with Pingram
- Engineering
- Tutorial
- SMS
- Java
Learn how to send SMS and email notifications in your Java application using Pingram. Includes setup, code samples, and security best practices.

YouTube Walkthrough
In this tutorial, you’ll learn how to send SMS and email notifications from your Java application using Pingram. We’ll walk through setting up your project, adding dependencies, and sending your first notifications.
Why Use Pingram for Java?
Sending notifications (SMS, email, etc.) from Java requires a reliable third-party service. Pingram offers a generous free tier (100 SMS and 3,000 emails per month), a simple API, and a dashboard for monitoring delivery and analytics.
Step 1: Create a Pingram Account
Go to Pingram and sign up for a free account. Copy your API key (pingram_sk_...) from the API Keys page in the dashboard. The free tier includes:
- 100 SMS messages per month
- 3,000 emails per month
No credit card required.
Step 2: Add pom.xml Dependency and Install
Add the Pingram Java SDK to your pom.xml. Check Maven Central for the latest version.
<dependency> <groupId>io.pingram</groupId> <artifactId>pingram</artifactId> <version>1.0.0</version></dependency>Then, install dependencies with Maven:
mvn installStep 3: Send Your First SMS and Email (Java Code Example)
Replace the placeholder with your Pingram API key and recipient info.
package com.example;
import io.pingram.Pingram;import io.pingram.model.*;
public class HelloWorld { public static void main(String[] args) { Pingram pingram = new Pingram("pingram_sk_...");
SendEmailRequest email = new SendEmailRequest() .type("welcome_email") .to("joe@example.com") .subject("Hello") .html("<p>Hello, world!</p>");
SendEmailApiResponse emailResponse = pingram.getEmail().emailSend(email); System.out.println("Email tracking ID: " + emailResponse.getTrackingId());
SendSmsRequest sms = new SendSmsRequest() .type("welcome_sms") .to("+15005550006") .message("Hello, world!");
SendSmsResponse smsResponse = pingram.getSms().smsSend(sms); System.out.println("SMS tracking ID: " + smsResponse.getTrackingId()); }}Key Points:
- Use your Pingram API key — never commit it to source control.
- The phone number must be in international format (e.g.,
+1for US/Canada). - Send email and SMS with separate
emailSend()andsmsSend()calls.
Security Best Practices
-
Keep Credentials Secret
Never expose your Pingram API key in frontend code or public repositories. -
Validate Recipients
Only send notifications to users you trust or have verified. -
Use Static Templates
Avoid including user-generated content in notification messages to prevent abuse. -
Implement Rate Limiting
Prevent users from triggering too many notifications in a short period.
Monitoring and Analytics
Pingram provides a dashboard to:
- View delivery status
- Track open and error rates
- Analyze notification performance
Feedback and Support
Questions or feedback? Reach out at support@pingram.io.
References: