Perl Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Perl Examples

Quick Start
Perl Unicode
Perl Byte Array
Perl Certs
Perl Email
Perl Encryption
Perl FTP
HTML-to-XML
Perl HTTP
Perl IMAP
Perl MHT
Perl MIME
Perl RSA
Perl S/MIME
Perl Signatures
Perl Socket
Perl Spider
Perl Tar
Perl Upload
Perl XML
Perl XMP
Perl Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Using GMail as your SMTP Server

Perl script showing how to use GMail as your SMTP server for sending email.

Download Perl Programming Example Scripts

# file: GMail.pl

# Perl script to send email using GMail as the SMTP server.
	
use chilkat;

$mailman = new chilkat::CkMailMan();
$mailman->UnlockComponent('anything for 30-day trial');

# Set your SMTP server's hostname
$mailman->put_SmtpHost('smtp.gmail.com');

# GMail requires a login/password to send mail.
# Strings containing a '@' should always be in single quotes.
$mailman->put_SmtpUsername('login@gmail.com');
$mailman->put_SmtpPassword('password');

# The default SMTP port is 25.  When using it, GMail requires STARTTLS.
$mailman->put_StartTLS(true);

# Alternatively, you may comment-out the STARTTLS line and instead use SSL
# on port 465 by commenting-in these 2 lines:
# $mailman->put_SmtpPort(465);
# $mailman->put_SmtpSsl(true);

# If you are connected to a network that blocks outbound port 25 connections,
# use GMail's alternative port 587.  You'll need STARTTLS, so uncomment the 
# STARTTLS line and make sure the two lines for SMTP SSL are commented out.
# $mailman->put_SmtpPort(587);

# Instantiate a new email object.
$email = new chilkat::CkEmail();
$email->put_Subject('Sending mail from Perl using GMail');
$email->put_Body('I sent this email using GMail in Perl over a secure channel!');
$email->put_From('Chilkat Support <support@chilkatsoft.com>');

# Add some recipients
$email->AddTo('Matt','matt@chilkatsoft.com');
$email->AddTo('TagTooga','admin@tagtooga.com');
    
$success = $mailman->SendEmail($email);
if (! $success)
    {
	$mailman->SaveLastError('lastError.txt');	
    }
else 
{
	# The log will contain information allowing you to verify
	# what actually happened.
	# If you see an error "Error authenticating server credentials!" this is 
	# normal and OK.
	$mailman->SaveLastError('lastInfo.txt');	
}






 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.