Sample code for 30+ languages & platforms
React Native

Send Email using smtp-mail.outlook.com with Password Authentication

See more SMTP Examples

Demonstrates how to send an email using smtp-mail.outlook.com using password authentication.

Chilkat React Native Downloads

React Native
import { Email, MailMan } from '@chilkat/react-native'

async function chilkatExample() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const mailman = new MailMan();

  mailman.smtpHost = 'smtp-mail.outlook.com';
  mailman.smtpPort = 587;
  mailman.startTLS = true;

  // Set the SMTP login/password
  mailman.smtpUsername = 'OFFICE365_USERNAME';
  mailman.smtpPassword = 'OFFICE365_PASSWORD';

  // Create a new email object
  const email = new Email();

  email.subject = 'This is a test';
  email.body = 'This is a test';
  email.from = 'My Name <my_office365_email@outlook.com>';
  email.addTo('Chilkat Admin', 'admin@chilkatsoft.com');

  try {
    await mailman.sendEmailAsync(email);
  } catch {
    console.log(mailman.lastErrorText);
    return;
  }

  console.log(mailman.smtpSessionLog);

  try {
    await mailman.closeSmtpConnectionAsync();
  } catch {
    console.log('Connection to SMTP server not closed cleanly.');
  }

  console.log('Email Sent!');
}