Docs
ServoyCloudSupportSamplesOpen SourceCommunity
  • Home
  • GUIDES
    • Platform Overview
    • Get Servoy
    • Get Started
      • Chapter 0
      • Chapter 1
      • Chapter 2
      • Chapter 3
      • Chapter 4
      • Chapter 5
    • Get Help
      • SuLA Instructions
      • SuLA Terms
    • Develop
      • Application Design
        • Forms
          • Layout Management
            • Simple Layout
            • Fully Responsive
              • Bootstrap 12-Grid
              • Flexbox
              • Custom Div
              • Collapsible Container
              • Simple Collapsible
              • Center Container
              • Inline Group Container
            • Abstract Form
          • Form Containers
            • Form Container
            • Tab Panel
            • Split Pane
            • Collapse
            • Accordion Panel
            • Form Component
            • List Form Component
          • Form Inheritance
          • Form Components
        • UI Components
          • Buttons and Text
            • Badge
            • Button
            • Data Label
            • Dropdown
            • Image
            • Label
          • Grids
            • Data Grid
            • Power Grid
            • Table
          • Input Controls
            • Calendar
            • Calendar Inline
            • Checkbox
            • Choice Group
            • Combobox
            • Group Buttons
            • Html Area
            • Input Group
            • Rating
            • Slider
            • Switch
            • Spinner
            • TextArea
            • Textbox
            • TextBoxGroup
            • Type Ahead
            • select2tokenizer
          • Media
            • Carousel
            • Embedded YouTube
            • File upload
            • Image label
            • Lightbox Gallery
            • MultiFile Upload
            • PDF JS Viewer
            • PDF Viewer
          • Mobile
            • Native Data List
            • Native Select
          • Navigation
            • Breadcrumbs
            • Navbar
            • sidenav
          • Visualization
            • DBTreeview
            • Progress Bar
            • Treeview
            • ChartJS
              • Data Labels Plugin
              • Funnel Chart
              • OutLabels Plugin
              • TreeMap
          • Specialized Components
            • Smart Document Editor
            • Servoy PDF Viewer
            • Fullcalendar Component
              • Fullcalendar
              • Fullcalendar Events
              • Migrating calendar from Smart and Web client to NG client
            • Fullcalendar Component 2
            • Canvas
            • Google Charts
            • Google Maps
            • svySignature
            • svywebcam
        • Styling and Themes
          • Default Theme Properties
          • CSS / LESS
          • Component Variants
          • Font Icons
        • Data Modeling
          • Databases
            • Tables
              • Columns
              • Calculations
              • Aggregations
              • Methods
              • Events / Triggers
              • Table security
            • Views
            • Procedures
          • Relations
          • Value Lists
          • Menus
          • In-Memory Databases
          • View Datasource
        • Modular Design
      • Programming Guide
        • Scripting the UI
          • Scripting Forms
          • Interacting with Components
          • Navigation
          • Windows, Dialogs and Popups
          • Events Manager
        • Working with Data
          • Concepts
          • Loading
          • Sorting
          • Iterating
          • Searching
            • Find mode
            • Query Builder
            • SQL String
          • Filtering
          • Editing
          • Validation
        • Automation and Scheduling
          • Batch Processor
          • Headless API
          • Scheduler API
        • Creating REST APIs
        • Consuming Webservices
        • Working with Files
          • File Plugin Basics
          • Images
          • Excel
          • PDF
          • JSON
        • Browser Utilities
          • Notifications
            • Web Notifications (Toastr)
            • Web Notifications (Native)
            • Block UI
          • Session Management
          • Keyboard Utilities
          • NG Utils
        • Sending and Receiving Email
        • Servoy Jasper Reports
          • Input Type
          • Display Mode
          • Output format
          • Jaspe Reports Viewer
        • Extensions
          • Modules
            • svyPhonegap
              • First Use Guide
              • Barcode Scanner
              • Browser
              • Camera
              • File
              • Fingerprint
              • Location
              • Network Interface
              • Phonegap
              • Printer
              • Push Notifications
            • svyAPI
              • Getting Started
            • svyLookup
              • Custom Templates
              • API Documentation
              • svyLookup v1
                • API Documentation v1.0.0
                • Base Form svyLookupTable v1.0.0
                • Base Form AbstractLookup v1.0.0
            • svyNavigation
              • API Documentation
                • API svyNavigation
                • API svyNavigationHistory
                • API svyNavigationUX
            • svyPopupFilter
              • Simple Filter Pickers
              • Custom Templates
              • API Documentation
                • API svyToolbarFilter
                • API svyPopupFilter
              • API Documentation v1
                • API svyToolbarFilter v1
                • API svyPopupFilter v1
            • svySearch
            • svySecurity
              • Overview
              • Token-based Auth and SSO (NEW!)
              • API Documentation
              • Getting Started
              • Tenant replication
              • Security Management Console
                • Classic Security Management Console
              • svySecurityUX
              • svyProperties
              • API Doc svyProperties
            • svyUtils
              • Log Manager
              • Log Manager Appenders
              • Smart Doc Editor Utils
              • Custom Dialogs
              • Excel Utils
                • Full API Reference
              • Crypto Utils
      • Security
        • Authentication
        • Permissions
          • UI Permissions
          • Data Permissions
          • Runtime Permissions
        • Audit Logging
        • OAuth
        • JWT
      • Multi-Language Support
      • Mobile Development
        • Getting Started
        • Mobile Design
        • Native Mobile Integrations
        • Building a Native Binary for the App Store
      • Native Desktop Development
        • NGDesktop UI plugin
        • NGDesktop Utils
        • NGDesktop File Plugin
    • Deploy
      • WAR Deployment
      • Docker Deployment
      • Server Configuration
        • Server Settings
        • Server Plugins
        • Database Servers
          • Locks
          • Transactions
          • Oracle
          • SQLServer
        • Client Sessions
        • Batch Processors
        • License Management
        • Monitoring
          • Server Log
          • Browser Console Log
          • Websocket Log
          • Query Performance
          • Client Performance
          • Client Event Tracing
          • Monitoring Servoy with JMX
      • NGClient deployment
      • Troubleshooting
      • Other Topics
        • Security: Cross-site Scripting
        • Running in an iFrame
    • Extend
    • Contribute
  • Reference
    • Servoy Core
      • Object Model
        • Database Server
          • Table
            • Column
            • Calculation
            • Method
            • Aggregation
          • View
          • Procedure
        • Solution
          • Form
          • Form Component
          • Relation
          • Relation Item
          • Table Node
          • Value List
          • Menu
          • Menu item
          • In-Memory Data Source
          • View Foundset Data Source
          • Variable
          • Column Info
          • Media
          • Layout Container
          • Method
        • i18n Message Key
      • Developer API
        • Globals
        • Forms
          • RuntimeForm
            • controller
            • containers
              • RuntimeContainer
            • elements
              • Component
              • RuntimeAccordionPanel
              • RuntimeBean
              • RuntimeButton
              • RuntimeCalendar
              • RuntimeCheck
              • RuntimeCombobox
              • RuntimeComponent
              • RuntimeDataButton
              • RuntimeDataLabel
              • RuntimeGroup
              • RuntimeHtmlArea
              • RuntimeImageMedia
              • RuntimeInsetList
              • RuntimeLabel
              • RuntimeListBox
              • RuntimePassword
              • RuntimePortal
              • RuntimeRadio
              • RuntimeChecks
              • RuntimeRadios
              • RuntimeRectangle
              • RuntimeRtfArea
              • RuntimeSpinner
              • RuntimeSplitPane
              • RuntimeTabPanel
              • RuntimeTextArea
              • RuntimeTextField
              • RuntimeWebComponent
        • JS Lib
          • Array
          • BigInt
          • Boolean
          • Date
          • Function
          • IterableValue
          • Iterator
          • JSON
          • Map
          • Set
          • Math
          • Namespace
          • Number
          • Object
          • Promise
          • QName
          • RegExp
          • Special Operators
          • Statements
          • String
          • XML
          • XMLList
        • Application
          • APPLICATION_TYPES
          • CLIENTDESIGN
          • DRAGNDROP
          • ELEMENT_TYPES
          • LOGGINGLEVEL
          • NGCONSTANTS
          • UICONSTANTS
          • CSSPosition
          • JSDimension
          • JSDNDEvent
          • JSEvent
          • JSLogger
          • JSLogBuilder
          • JSPoint
          • JSUpload
          • JSWindow
          • JSBounds
          • Renderable
          • UUID
        • SolutionModel
          • ALIGNMENT
          • ANCHOR
          • BEVELTYPE
          • CURSOR
          • DEFAULTS
          • FONTSTYLE
          • MEDIAOPTION
          • PAGEORIENTATION
          • PRINTSLIDING
          • SCROLLBAR
          • TITLEJUSTIFICATION
          • TITLEPOSITION
          • UNITS
          • JSBean
          • JSButton
          • JSCalculation
          • JSComponent
          • JSDataSourceNode
          • JSField
          • JSForm
          • JSLabel
          • JSMedia
          • JSMethod
          • JSPart
          • JSPortal
          • JSRelation
          • JSRelationItem
          • JSStyle
          • JSTab
          • JSTabPanel
          • JSValueList
          • JSVariable
          • JSTitle
          • JSChecks
          • JSCombobox
          • JSHeader
          • JSInsetList
          • JSList
          • JSPassword
          • JSRadios
          • JSText
          • JSTextArea
          • JSWebComponent
          • JSLayoutContainer
        • Database Manager
          • QUERY_COLUMN_TYPES
          • SQL_ACTION_TYPES
          • JSColumn
          • JSDataSet
          • JSBaseRecord
          • JSBaseSqlRecord
          • JSBaseFoundset
          • JSBaseSQLFoundset
          • JSFoundSet
          • JSFoundSetUpdater
          • JSRecord
          • JSRecordMarker
          • JSRecordMarkers
          • JSTable
          • JSTableFilter
          • MenuFoundSet
          • MenuItemRecord
          • QBAggregate
          • QBAggregates
          • QBCase
          • QBCaseWhen
          • QBColumn
          • QBColumns
          • QBCondition
          • QBFunction
          • QBFunctions
          • QBGroupBy
          • QBJoin
          • QBJoins
          • QBLogicalCondition
          • QBParameter
          • QBParameters
          • QBPart
          • QBResult
          • QBSearchedCaseExpression
          • QBSelect
          • QBSort
          • QBSorts
          • QBTableClause
          • QBWhereCondition
          • ViewFoundSet
          • ViewRecord
        • Events Manager
          • EVENTS_AGGREGATION_TYPES
          • EventType
        • Menus
          • JSMenu
          • JSMenuItem
        • JSMenuDatasource
        • Utils
        • Client Utils
          • JSBlobLoaderBuilder
        • History
        • Security
        • i18n
        • ServoyException
          • DataException
        • JSUnit
        • Datasources
          • DBDataSource
          • DBDataSourceServer
          • JSConnectionDefinition
          • JSDataSource
          • MemDataSource
          • MenuDataSource
          • SPDataSource
          • SPDataSourceServer
          • ViewDataSource
        • JSViewDatasource
        • servoyDeveloper
        • enum
    • Extensions
      • UI Components
        • Buttons and Text
          • Badge
          • Button
          • Data Label
          • Drop Down
          • Image
          • Label
        • Form Containers
          • Accordion Panel
          • Collapse
          • Form Container
          • Form Component Container
          • List Form Component
          • Default Loading Indicator
          • Error Bean
          • Portal
          • Responsive Container
          • Servoy Default Navigator
          • Slider
          • Split Pane
          • TabPanel
        • Grids
          • Data Grid
          • Power Grid
          • Table
        • Input Controls
          • Calendar
          • Calendar Inline
          • Checkbox
          • Choice Group
          • Combobox
          • Floatinglabel Calendar
          • Floatinglabel Combobox
          • Floatinglabel Textarea
          • Floatinglabel Textbox
          • Floatinglabel Type Ahead
          • Group Buttons
          • Html Area
          • Input Group
          • Rating
          • Select2tokenizer
          • Slider
          • Spinner
          • Switch
          • TextArea
          • TextBox
          • TextBox Group
          • Type Ahead
        • Media
          • Carousel
          • Embedded YouTube
          • File upload
          • Image label
          • Lightbox Gallery
          • MultiFile Upload
          • PDF JS Viewer
          • PDF Viewer
        • Mobile
          • Native Data List
          • Native Select
        • Navigation
          • Breadcrumbs
          • Navbar
          • sidenav
        • SmartDocEditor
          • Smart Document Editor
        • Visualization
          • Canvas
          • Chart
          • Custom List
          • DBTreeview
          • Foundset List
          • Fullcalendar
          • Gauge
          • Google Maps
          • Kanban
          • Progress Bar
          • Treeview
      • Server Plugins
        • amortization
          • AmortizationCalculation
          • Polynomial
        • clientmanager
          • Broadcaster
          • JSClientInformation (cm)
        • excelxport
        • file
          • JSFile
          • JSProgressMonitor
        • headlessclient
          • JSClient
        • http
          • HTTP_STATUS
          • Cookie
          • DeleteRequest
          • GetRequest
          • HeadRequest
          • HttpClient
          • HttpClientConfig
          • OptionsRequest
          • PostRequest
          • PutRequest
          • Response
          • TraceRequest
          • PatchRequest
          • JSFileUpload
        • images
          • JSImage
        • jwt
          • Algorithm
          • Builder
          • JWTClaims
        • mail
          • Attachment
          • MailMessage
        • maintenance
          • JSClientInformation
          • JSColumnObject
          • JSServer
          • JSTableObject
        • mobileservice
          • OfflineDataDescription
        • oauth
          • ClientAuthentication
          • CustomApiBuilder
          • OAuthProviders
          • OAuthRequest
          • OAuthResponse
          • OAuthResponseBinary
          • OAuthResponseJSON
          • OAuthResponseText
          • OAuthService
          • OAuthServiceBuilder
          • OAuthTokenExtractors
          • RequestType
        • pdf_output
        • rawSQL
        • RestWs plugin
        • rest_ws
          • WsContents
          • WsCookie
          • WsRequest
          • WsResponse
        • scheduler
        • serialize
        • textxport
          • DataProviderExport
          • TabExporter
        • udp
          • JSPacket
        • XmlReader
          • XmlNode
      • Browser Plugins
        • Block UI
        • Block UI (ref)
        • Dialogs Plugin
        • Idle
        • Idle (ref)
        • Key Listener
        • Key Listener (ref)
        • NGDesktop File
        • NGDesktop File (ref)
        • NGDesktop UI (ref)
        • NGDesktop Utils (ref)
        • NG Utils (ref)
        • Office Javascript API for Servoy
        • Phonegap
        • Web Notifications (Native)
        • Web Notifications (Toastr)
        • Window Plugin
        • Font Awesome
      • Modules
        • Smart Doc Editor Utils
        • svyAPI
          • Getting Started
        • svyLookup
          • Custom Templates
          • API Documentation
          • svyLookup v1
            • API Documentation v1.0.0
            • Base Form svyLookupTable v1.0.0
            • Base Form AbstractLookup v1.0.0
        • svyLookupExample
        • svyNavigation
          • API Documentation
            • API svyNavigation
            • API svyNavigationHistory
            • API svyNavigationUX
        • svyNavigationUX
        • svyNavigationUXSample
        • svyPopupFilter
          • Simple Filter Pickers
          • Custom Templates
          • API Documentation
            • API svyToolbarFilter
            • API svyPopupFilter
          • API Documentation v1
            • API svyToolbarFilter v1
            • API svyPopupFilter v1
        • svyProperties
        • svySearch
        • svySecurity
          • Overview
          • Token-based Auth and SSO (NEW!)
          • API Documentation
          • Getting Started
          • Tenant replication
          • Security Management Console
            • Classic Security Management Console
          • svySecurityUX
          • svyProperties
          • API Doc svyProperties
        • svySecurityConsole
        • svySecurityUX
        • svyUtils
          • Log Manager
          • Log Manager Appenders
          • Smart Doc Editor Utils
          • Custom Dialogs
          • Excel Utils
          • Full API Reference
          • Crypto Utils
        • svyUtils$Excel
        • svyUtils$NGClient
        • svyUtils$customDialogs
        • svyUtils$logManagerAppenders
        • svyUtils$tableGrid
      • Layout
        • Boostrap 12grid layout
          • Collapsible Container
          • Simple Collapsible
          • Center Container
          • Inline Group Container
          • Flexbox Layout
      • Solutions
        • Sample Application
          • Tutorial Part 1
          • Tutorial Part 2
      • Packages
        • UI Component Packages
          • Advanced Renderers
          • Bootstrap Components
          • Bootstrap Extra Components
          • Canvas
          • Chart JS
          • Fullcalendar Component
          • googlemaps
          • kanban
          • Servoy Core
          • Servoy Extra Components
          • Servoy NG-Grids
          • Servoy PDF Viewer
          • smartDocumentEditor
        • Browser Plugin Packages
          • Block UI
          • Core NG only Services
          • Key Listener
          • NGDesktop File
          • NGDesktop UI
          • NGDesktop Utils
          • Web Notifications
          • Idle Web Service
    • Servoy Developer
      • Menu
        • File
        • Edit
        • Source
        • Refactor
        • Navigate
        • Search
        • Project
        • Actions
        • Run
        • Window
        • Help
      • Toolbar
      • Solution Explorer
        • Resources
          • Database Servers
            • Database Server
              • Procedures
              • Tables
              • Views
          • Security
          • i18n
        • All Solutions
          • Solution
          • Active Solution
            • Scopes
              • Scope
                • Variables
            • Forms
              • Working Set
              • Form
                • Controller
                • Variables
                • Elements
                • Relations
            • Form Components
              • Form Component
            • Relations
              • Relation
            • ValueLists
              • ValueList
            • Menus
              • Menu
                • MenuItem
            • Media
              • Folder
              • File
            • DataSources
              • In Memory DataSources
                • In Memory DataSource
              • View Foundsets DataSources
                • View Foundset DataSources
            • Servoy Packages
              • Package
            • Modules
              • Module
        • Solution Explorer Contextual List
      • Views
        • Command Console
        • Console
        • Problems
        • Tasks
        • Bookmarks
        • Search
        • Form Hierarchy
        • Help
        • JUnit
        • Outline
        • Profiler
        • Properties
        • Project Explorer
        • Call Hierarchy
      • Editors and Wizards
        • Property configurator for columns
        • Relation Editor
        • Text Format Editor
        • Date Format Editor
        • Number Format Editor
        • Database Synchronization Wizard
        • Security Editor
        • SQL Editor
        • i18n Editor
        • File Import Wizard
        • File Export Wizard
        • WAR Export Wizard
        • NGDesktop Export Wizard
        • Table Editor
        • Metadata Synchronization Wizard
        • Database Server Connection Editor
        • Text Property Editor
        • Valuelist Editor
        • Form Editor
          • Parts of the Form Editor
          • Designing a Form
          • Layout Tools
          • Using Containers
          • Creating and Using Forms
          • Using Servoy Beans
          • Using Shapes
          • Form Editor Subtabs
          • [Tips and Shortcuts][reference/servoy-developer/object-editors/form-editor-tips_and_shortcuts.md]
          • Editong a Responsive LayoutForm
          • CSS Positioning
        • Form Hierarchy
        • Component Properties Editor
        • Variable Editor
        • Method Selection Wizard
        • New Solution Wizard
        • Application Event Types Editor
        • New Form Wizard
        • Form Dataproviders Configurator
        • Servoy Resource Locator
        • Datasource Selection Wizard
        • Sorting Fields Wizard
        • Scripting Editor
          • Getting Started-Overview of Script Editor
          • Code Writing Features
          • Code Navigation
          • Code Rewriting Tools
          • Refactoring
          • Code Formatting
          • Script Editor Tips and Shortcuts
          • Unit Tests
        • Theme Editor
          • General Properties
          • Sidenav Properties
          • Navbar Properties
          • Tabs Properties
          • Windows Properties
          • Dialogs Properties
          • Tables Properties
          • Breadcrumb specific style Properties
          • Brand colors Properties
          • Validations Properties
          • Margins and Padding Properties
        • Editor Selection
        • Run Configurations
        • Debug Configurations
        • Externalize Strings Wizard
        • Font Chooser Wizard
        • Color Chooser Wizard
        • Project Properties Configurator
        • Move Wizard
        • External Tools Configurations
        • About Servoy Developer
        • Servoy Developer Installation Details
        • Eclipse Marketplace Wizard
        • Install Available Software Wizard
        • Cheat Sheet Selection Wizard
        • Servoy Developer Help Wizard
        • Switch to Editor Wizard
        • Find Actions Wizard
        • Customize Perspective Configurator
        • Quick Search Wizard
        • Search Wizard
        • Encoding Wizard
        • Task Wizard
        • Find - Replace Wizard
        • Properties Editor
        • New Project Wizard
        • New Method Wizard
        • New Menu Wizard
          • New MenuItem Wizard
        • Menu Editor
        • ServoyMenu Selection Wizard
        • JSMenu compatible component selector
        • Permissions Configuration Dialog
      • Project File Structure
        • Servoy Installation Directory
          • servoy.properties
        • Workspace Folder
          • Resources Directory
            • Database Information (.dbi) Files
          • Solution Folder
      • Package Manager
      • Preferences
      • Property Types for components / services
      • Debugger
        • Debug Explorer
        • Breakpoints
          • Breakpoint Properties
        • Variables
        • Expressions
        • Interactive Console
    • Application Server
    • Servoy Cloud
      • Cloud Control Center
        • Home
          • Setup Namespace
          • User profile
            • My Profile
            • Support
        • Download IDE
        • Application Overview
          • Applications
            • Pipelines
              • Jobs
                • Packages
                  • Commits
                  • Artifacts
                  • Configuration
                  • Quality reports
                  • Build markers
                • Job Configuration
                  • Build and Deploy or Build
                  • Mobile
                  • Desktop
            • Environments
              • Metrics
                • Users
                • Databases
                  • Metrics
                • System Health
                • Log Activity
                • App performance
                • Query performance
              • Cloud reporting
            • Security
              • Permissions
              • Tenants
            • Reports
            • Security Login Designer
              • Single Sign-On
                • Sign in with Google
                • Sign in with Microsoft
          • Code Repositories
        • Project Management
          • Tickets
          • Backlog
          • Active Sprints
        • User Management
          • Users
          • Roles
        • Administration
          • Security
            • ServoyCloud Roles
          • Credentials
          • Settings
        • Add-Ons
      • Database Backup
      • E2E Cypress Testing
        • Using Cypress
      • On-Premise Deployment
      • Privacy policy (ServoyAI)
      • FAQ
      • Migrate to Servoy Cloud
    • Extensions Developement
      • Component and Services
        • Component Development
        • Service Development
        • Tools and Dev Tips to use for Component/Service developement
        • Manifest (.mf file)
        • Specification (.spec file)
          • Property Types
            • Array property types
            • Custom object property types
            • Findmode property type
            • Foundset property type
            • Tags
        • Directives And Filters
          • Sablotabsequence
        • Console (serverside)
        • ServoyApi (serverside)
      • Serverside Plugins
        • Data Convertors and Validators
        • UI Convertors
  • Release notes
    • Release notes
      • 2025.03
      • 2024.03 (LTS)
      • 2023.03 (LTS)
      • 2025.03 (Servoy Cloud)
      • 2024.12
      • 2024.12 (Servoy Cloud)
      • 2024.09
      • 2024.09 (Servoy Cloud)
      • 2024.06
      • 2024.06 (Servoy Cloud)
      • 2024.03 (Servoy Cloud)
      • 2023.12
      • 2023.12 (Servoy Cloud)
      • 2023.09
      • 2023.09 (Servoy Cloud)
      • 2023.06
      • 2022.03 (LTS)
      • 2022.12 What's new
      • 2022.12
      • 2022.09 What's new
      • 2022.09
      • 2022.06 What's new
      • 2022.06
      • 2021.03.3 (LTS)
Powered by GitBook
On this page
  • Overview
  • Email Configuration
  • Configuring Mail Settings
  • Developer Override Address
  • Basic Examples
  • Simple Email
  • Multiple Recipients
  • Reply-To Address
  • Attachments
  • Overriding SMTP Properties
  • Including Markup
  • Sending Bulk Mail
  • Handling Errors
  • Receiving Mail

Was this helpful?

  1. GUIDES
  2. Develop
  3. Programming Guide

Sending and Receiving Email

Placeholder for the mail plugin

PreviousNG UtilsNextServoy Jasper Reports

Last updated 15 days ago

Was this helpful?

Overview

The Mail Plugin in Servoy allows applications to send and receive emails programmatically. Emails can be sent using the SMTP protocol, while the plugin supports receiving emails via the older POP3 protocol. It supports various features including:

  • Sending emails in plain text or HTML format.

  • Adding attachments (binary or text).

  • Handling multiple recipients via TO, CC, and BCC fields.

  • Configuring SMTP properties dynamically.

  • Receiving emails with attachments through POP3.

The provides comprehensive details about using the plugin for sending and receiving emails, including methods for attachments, error handling, and configuration. An external resource comparing and protocols offers insights into their differences and use cases, useful for understanding which protocol to use for email retrieval.

Email Configuration

Configuring Mail Settings

Mail settings can be configured in the servoy.properties file or through the Admin Page under the Server Plugins section. Key points include:

  • For SMTP relay setup, obtain host and authentication details from your email provider (e.g., Gmail).

  • Defaults: If no SMTP relay is provided, the app server attempts to send mail on port 25, which may be blocked in corporate networks.

Example servoy.properties configuration:

mail.smtp.host=smtp.sendgrid.net /*server*/
mail.smtp.auth=true
mail.smtp.user=username /*API Key Name*/
mail.smtp.password=password /*API Key Value*/
mail.smtp.port=587

Servoy Admin Page:

This page is used to configure the settings for the Mail Server Plugin in Servoy. These settings define how the server connects to mail servers for sending and receiving emails, including support for SMTP, POP3, SSL/TLS, and other related options. Each field allows you to fine-tune the behavior of the mail service to match your server requirements, such as connection timeouts, authentication credentials, and security protocols. All the properties configured in the Servoy Admin Page, under the Server Plugin section's Mail Server Plugin subsection, will also appear in the servoy.properties file. This ensures consistency and allows manual adjustments if needed outside the admin interface.

The key configuration options include:

  • SMTP Settings: For defining the outgoing mail server's host, port, authentication, and security details.

  • POP3 Settings: For configuring the incoming mail server's host and APOP authentication support.

  • Development Overrides: To specify developer-specific overrides like a default email address for testing purposes.

Each option includes an info link for additional details on its purpose and usage:

  • mail.server.allowUnauthenticatedRMIAccess: Allow mailserver access for unauthenticated smart (rmi) client (true/false), defaults to false.

  • mail.pop3.host: The name of POP3 server to recieve mails from.

  • mail.pop3.apop.enable: Whether or not to use APOP for authentication (true/false), defaults to false.

  • mail.smtp.host: The name of SMTP server to deliver the mails to.

  • mail.smtp.port: The port of SMTP server to deliver the mails to.

  • mail.from: Default 'from' address if none is specified.

  • mail.smtp.auth: Use authentication (true/false), defaults to false.

  • mail.smtp.username: Specify username if using authentication.

  • mail.smtp.password: Specify password if using authentication.

  • mail.smtp.connectiontimeout: Socket connection timeout value in milliseconds. Default is infinite timeout.

  • mail.smtp.timeout: Socket I/O timeout value in milliseconds. Default is infinite timeout.

  • mail.smtp.ssl.enable: Use SSL (true/false), defaults to false.

  • mail.smtp.starttls.enable: Use START/TLS (true/false), defaults to false.

  • mail.development.override.address: Specify an email address to which all email will be send instead of the specified To, Cc and Bcc addresses. The specified to, Cc and Bcc addresses will be added to the Subject.

Developer Override Address

For testing purposes, configure a developer override address:

mail.override.to=developer@example.com

This ensures all emails are sent to a single address, regardless of the recipient specified in the code.

Basic Examples

Simple Email

Send a basic email: This example demonstrates sending a simple email with the essential fields: recipient, sender, subject, and message body.

var success = plugins.mail.sendMail(
    'recipient@example.com', // Recipient email address
    'sender@example.com',   // Sender email address
    'Subject Line',         // Subject of the email
    'Email Body Text'       // Main body content of the email
);

if (!success) {
    application.output('Failed to send email: ' + plugins.mail.getLastSendMailExceptionMsg());
}

Explanation: Parameters:

  • recipient: Specifies the recipient's email address.

  • sender: Specifies the sender's email address.

  • subject: Defines the subject of the email.

  • body: Contains the main text or content of the email. If the email fails to send, the getLastSendMailExceptionMsg method retrieves details about the error.

Multiple Recipients

Send email to multiple recipients with CC and BCC: This example shows how to send an email to multiple recipients using the TO, CC, and BCC fields.

var success = plugins.mail.sendMail(
    'to@example.com,to2@example.com', // Comma-separated list of TO recipients
    'sender@example.com',            // Sender email address
    'Subject Line',                  // Subject of the email
    'Email Body',                    // Main body content of the email
    'cc@example.com',                // CC (carbon copy) recipients
    'bcc@example.com'                // BCC (blind carbon copy) recipients
);
  
if (!success) {
    application.output('Failed to send email: ' + plugins.mail.getLastSendMailExceptionMsg());
}

Explanation: Parameters:

  • to: Specifies primary recipients of the email.

  • sender: Specifies the sender's email address.

  • subject: Defines the subject of the email.

  • body: Contains the main text or content of the email.

  • cc: Specifies recipients who receive a copy of the email and are visible to all recipients.

  • bcc: Specifies recipients who receive a copy of the email but remain hidden from other recipients. Note: BCC recipients remain hidden from other recipients.

Reply-To Address

Specify a different reply-to address: This example sends an email with a different Reply-To address.

var success = plugins.mail.sendMail(
    'to@example.com',                       // Recipient email address
    'sender@example.com,replyto@example.com', // Sender email address and Reply-To address
    'Subject Line',                        // Subject of the email
    'Email Body'                           // Main body content of the email
);

Explanation:

  • The sender parameter includes both the sender's email address and a Reply-To address, separated by a comma.

  • The Reply-To address specifies where any email replies should be sent, instead of the sender's email address.

Attachments

Binary attachment

var attachment = plugins.mail.createBinaryAttachment(
    'file.txt',                   // Name of the file as it appears in the email
    plugins.file.readFile('path/to/file.txt') // Reads the binary content of the file
);

var success = plugins.mail.sendMail(
    'to@example.com',
    'sender@example.com',
    'Subject Line',
    'Email Body',
    null,
    null,
    [attachment]
);

Explanation: Parameters:

  • filename: The name displayed for the attachment in the email.

Text attachment

var attachment = plugins.mail.createTextAttachment(
    'notes.txt',                  // Name of the text file to appear in the email
    'This is the content of the attachment' // Content of the text attachment
);

var success = plugins.mail.sendMail(
    'to@example.com',             // Recipient email address
    'sender@example.com',         // Sender email address
    'Subject with Text Attachment', // Subject of the email
    'Email body content',         // Main body content of the email
    null,                         // No CC recipients
    null,                         // No BCC recipients
    [attachment]                  // Attach the text file created above
);

if (!success) {
    application.output('Failed to send email: ' + plugins.mail.getLastSendMailExceptionMsg());
}

Explanation:

  • The createTextAttachment method is used to create a text attachment with a specified file name and content.

  • The sendMail method includes this attachment in the email sent to the recipient.

  • Error handling ensures any issues during email sending are logged for troubleshooting.

Overriding SMTP Properties

SMTP settings can be dynamically overridden, which is especially useful for multi-tenant applications.

Example:

var properties = [
    'mail.smtp.host=smtp.tenantdomain.com', // SMTP host for tenant's email server
    'mail.smtp.user=user',                 // Username for SMTP authentication
    'mail.smtp.password=pass'             // Password for SMTP authentication
];

var success = plugins.mail.sendMail(
    'to@example.com',
    'sender@example.com',
    'Subject Line',
    'Email Body',
    null,
    null,
    null,
    properties
);

Explanation: Parameters:

  • mail.smtp.host: Specifies the SMTP server address.

  • mail.smtp.user: Sets the username for authenticating with the SMTP server.

  • mail.smtp.password: Sets the password for authenticating with the SMTP server. This dynamic property configuration is helpful when each tenant has unique email server settings.

Including Markup

HTML emails can include inline images and other markup.

Example: This example illustrates how to send an HTML email with embedded images using a content ID (cid).

var htmlBody = '<html><body><h1>Hello</h1><p>This is an HTML email.</p><img src="cid:embedded"/></body></html>';
var imageAttachment = plugins.mail.createBinaryAttachment('embedded', plugins.file.readFile('path/to/image.jpg'));
var success = plugins.mail.sendMail(
    'to@example.com',
    'sender@example.com',
    'HTML Email',
    htmlBody,
    null,
    null,
    [imageAttachment]
);

Explanation: Parameters:

  • htmlBody: Defines the HTML structure of the email content. The cid placeholder links the embedded image to display inline in the email. This example demonstrates creating an HTML email. The cid placeholder links the embedded image to the email body, making it display inline.

Sending Bulk Mail

Example: In this example, each recipient in the array receives an individual email. Using a loop ensures that recipients don’t see each other’s addresses.

var recipients = [
    'user1@example.com', // First recipient's email address
    'user2@example.com'  // Second recipient's email address
];

for (var i = 0; i < recipients.length; i++) {
    var success = plugins.mail.sendBulkMail(
        recipients[i],
        'sender@example.com',
        'Bulk Email',
        'Hello, this is a bulk email.'
    );
    if (!success) {
        application.output('Failed to send to ' + recipients[i]);
    }
}

Explanation: Parameters:

  • recipients: An array containing email addresses of the recipients. Each address is processed in a loop to send emails individually, ensuring privacy. This loop demonstrates sending bulk emails to multiple recipients, sending each email individually.

Handling Errors

Always check for errors after sending emails:

var success = plugins.mail.sendMail('to@example.com', 'sender@example.com', 'Subject', 'Body');
if (!success) {
    var errorMessage = plugins.mail.getLastSendMailExceptionMsg();
    application.output('Error: ' + errorMessage);
}

Receiving Mail

Example: This example retrieves emails from a POP3 server, iterates through them, and logs their sender and subject.

var messages = plugins.mail.receiveMail(
    'username',                                // Username for POP3 authentication
    'password',                                // Password for POP3 authentication
    true,                                      // Whether to leave messages on the server
    0,                                         // Receive mode: 0 (full messages)
    null,                                      // Only messages with a specific sent date (null = all messages)
    ['mail.pop3.host=pop3.example.com']        // POP3 host configuration
);

if (messages) {
    for (var i = 0; i < messages.length; i++) {
        var msg = messages[i];
        application.output('From: ' + msg.getFromAddresses());
        application.output('Subject: ' + msg.getSubject());
    }
} else {
    application.output('Failed to retrieve messages.');
}

Explanation: Parameters:

  • username: POP3 account username.

  • password: POP3 account password.

  • leaveMsgsOnServer: If true, messages are not deleted from the server after retrieval.

  • receiveMode: Determines the level of message content retrieved (0 for full messages).

  • onlyReceiveMsgWithSentDate: Filters messages by their sent date (null for no filter).

mail.mime.charset: Specify the name of the charset to use for mail encoding (leave emtpy for system default), see forinfo which charset names are usable.

This example creates a binary attachment using a local file. The method reads the file and prepares it for inclusion in the email.

binarydata: The file content read as binary data using the method. This method prepares the attachment to be included in an email.

Use to send emails in bulk, avoiding auto-replies like "Out of Office".

Use the method to retrieve messages from a POP3 server.

properties: Configures the POP3 server settings, including the host address. This example connects to a POP3 mail server to retrieve emails. The method returns an array of messages, which are processed to extract details like the sender and subject.

http://java.sun.com/j2se/1.4.2/docs/api/java/nio/charset/Charset.html
createBinaryAttachment
readFile
sendBulkMail
receiveMail
receiveMail
IMAP
POP
Mail Plugin Documentation