Dart
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final mailman = CkMailMan();
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
final email = CkEmail();
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 {
mailman.sendEmail(email);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print(mailman.smtpSessionLog);
try {
mailman.closeSmtpConnection();
} on ChilkatException {
print('Connection to SMTP server not closed cleanly.');
}
print('Email Sent!');
}