Perl
Perl
Quickly Send a Simple Email
See more SMTP Examples
Demonstrates the Chilkat MailMan.QuickSend method, which sends a simple email to a single recipient without requiring the application to create an Email object. The arguments are the from address, the to address, the subject, the body, and the SMTP server hostname. This example sends a plain-text message in one call.
Background:
QuickSend is a convenience for the most common case: one plain-text message to one recipient. It skips the build-an-Email-object step, so it's ideal for quick notifications and alerts. When you need more — HTML bodies, attachments, multiple recipients, Cc/Bcc, or custom headers — build an Email object and use SendEmail instead. Authentication settings still come from the MailMan properties.Chilkat Perl Downloads
use chilkat();
$success = 0;
# Demonstrates the MailMan.QuickSend method, which sends a simple email to a single
# recipient without requiring the application to create an Email object. The arguments are
# the from address, the to address, the subject, the body, and the SMTP server hostname.
$mailman = chilkat::CkMailMan->new();
# SMTP authentication settings (the SMTP server hostname is passed to QuickSend).
$mailman->put_SmtpPort(465);
$mailman->put_SmtpSsl(1);
$mailman->put_SmtpUsername('user@example.com');
$mailman->put_SmtpPassword("myPassword");
# Send a simple email in one call.
$success = $mailman->QuickSend('alice@example.com','bob@example.com',"Quick hello","This is a quick message.","smtp.example.com");
if ($success == 0) {
print $mailman->lastErrorText() . "\r\n";
exit;
}
print "Email sent." . "\r\n";
# Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
# connects and authenticates -- using the property settings above -- whenever a server
# operation requires it. Calling the explicit connect/authenticate methods can still be
# helpful to determine whether a failure occurs while connecting or while authenticating.