Ruby Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Ruby
Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
SFTP
SMTP
Socket / SSL
Spider
SSH
SSH Key
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
DH Key Exchange
DSA
LZW

 

 

 

 

 

 

 

SMTP Authentication

This article discusses SMTP authentication when using the Chilkat Ruby module for sending email.

Download Ruby Programming Example Scripts

# file: SmtpAuthentication.rb

require 'chilkat'

# About SMTP Authentication when sending email.
mailman = Chilkat::CkMailMan.new()
mailman.UnlockComponent("anything for 30-day trial")

# Set your SMTP server's hostname
mailman.put_SmtpHost("smtp.comcast.net")

# If your SMTP server requires a authentication, set username/password
mailman.put_SmtpUsername("***")
mailman.put_SmtpPassword("***")

# Your SMTP server may or may not require authentication.  It often depends
# upon the location where the SMTP client is making the connection.  If the
# SMTP server is behind a firewall, it is often administered such that clients
# connecting from the same side of the firewall (i.e. within the network) can
# send email without authentication.  However, connections originating from
# outside the firewall DO require authentication.  This is quite often the
# case with cable modem and DSL ISP's.  
# If authentication is required, different SMTP servers support different authentication
# methods, some of which are more secure than others.  In the least secure scenario,
# your login/password is transmitted in clear-text (i.e. unencrypted) over the TCP/IP
# connection to the SMTP server.  This is with the "LOGIN" method.
# The "PLAIN" SMTP authentication method is effectively no better because the information
# is simply Base64 encoded.  The CRAM-MD5 and NTLM methods are secure because the
# login/password is sent encrypted.  However, if your connection to the SMTP server is
# SSL, or if you are using the STARTTLS option, it doesn't matter if the authentication
# method is LOGIN or PLAIN because the TCP/IP connection is SSL anyway.
# By default, Chilkat will choose the most secure authentication method available
# (as announced by the SMTP server during the initial "hello" handshake).
# If for some reason there is a problem, or if you desire less-secure authentication,
# you may explicitly set the SmtpAuthMethod property to: "LOGIN", "PLAIN", "CRAM-MD5", or "NTLM".
mailman.put_SmtpAuthMethod("LOGIN")

# Create an e-mail object
email = Chilkat::CkEmail.new()
email.put_Subject("How to send e-mail in the Ruby programming language")
email.put_Body("Email sent from a Ruby script")
email.put_From("Chilkat Support <support@chilkatsoft.com>")

# Add a few recipients...
email.AddTo("Matt","matt@chilkatsoft.com")
email.AddTo("TagTooga","admin@tagtooga.com")

# Send the email
success = mailman.SendEmail(email)
if not success
	mailman.SaveLastError("lastError.txt");
end




 

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

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