
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
uk.co.jakebreen:android-sendgrid
Advanced tools
An easy to use Android library utilising the SendGrid v3 API
A simplified Android email library utilising SendGrid's v3 API that targets minSdkVersion 16.
Use with JitPack and implement in your app
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation 'com.github.jakebreen:android-sendgrid:1.3.1'
}
Create an instance of the SendGrid library tied to your API key.
SendGrid sendGrid = SendGrid.create(@NonNull String apiKey)
Create a SendGridMail and provide the required attributes.
SendGridMail mail = new SendGridMail()
mail.addRecipient(@NonNull String email, @Nullable String name)
mail.setFrom(@NonNull String email, @Nullable String name)
mail.setSubject(@NonNull String subject)
mail.setContent(@NonNull String body)
Set a plain text or a html text content body, when using a template neither of these content variables need to be set.
mail.setContent(@NonNull String body)
mail.setHtmlContent(@NonNull String body)
Send a mail with the library's SendTask.
SendTask task = new SendTask(sendGrid);
SendGridResponse response = task.send(mail);
Send a mail with RxJava.
Single.fromCallable(sendGrid.send(mail))
.subscribeOn(Schedulers.io())
.subscribe(response -> {
if (response.isSuccessful()) {
// ...
}
}
);
Send requests return a SendGridResponse that contains the success state of the request and the associated HTTP response code. A failed request will contain the error message from the API.
response.isSuccessful()
response.getCode()
response.getErrorMessage()
Additional SendGridMail methods that aren't required to send an email include templates, tracking, carbon copies, attachments and others
mail.addAttachment(@NonNull File file)
mail.addAttachment(@NonNull Uri uri)
mail.addRecipientCarbonCopy(@NonNull String email, @Nullable String name)
mail.addRecipientBlindCarbonCopy(@NonNull String email, @Nullable String name)
mail.setReplyTo(@NonNull String email, @Nullable String name)
mail.setSendAt(@NonNull int sendAt)
mail.setClickTrackingEnabled(@NonNull Boolean enabled)
mail.setOpenTrackingEnabled(@NonNull Boolean enabled)
mail.setSubscriptionTrackingEnabled(@NonNull Boolean enabled)
mail.setUnsubscribeGroupId(@NonNull int groupId)
mail.setUnsubscribeGroupIds(@NonNull int groupId, List<Integer> groupIds)
Transactional email templates and custom data can be applied to the SendGridMail in the form of a JSONObject structured into key/value pairs
mail.setTemplateId(@NonNull String templateId)
mail.setDynamicTemplateData(@NonNull JSONObject jsonObject)
// JSONObject structured into key/value pairs
final JSONObject templateData = new JSONObject();
templateData.put("forename", "Jane");
templateData.put("surname", "Doe");
templateData.put("message", "Hello, This is my email");
mail.setDynamicTemplateData(templateData)
A test app included when cloning the library to test the library with file attachments, uses RxJava2. Feel free utilise this app.
FAQs
An easy to use Android library utilising the SendGrid v3 API
We found that uk.co.jakebreen:android-sendgrid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.