Send email using SMTP
Article Source: 山 夜
Http://www.33d9.com
SMTP's work mode?
The Simple Mail Transfer Protocol is one of the core Internet Protocol (IP), and its design is to reliably transmit email.
The initial conception of SMTP is relatively simple. The user or application (here is duwamish online),
These include recipient email addresses (such as "johndoe@somecompany.com"), email topics and mail content.
The first step in passing the message is to transfer the message to the specified SMTP server. SMTP server according to the recipient email address
Domain name (such as "SomeCompany.com"), start communication with the Domain Name System (DNS) server, DNS server will look
And return the host name of the target SMTP server (such as "mail.somecompany.com").
Finally, the SMTP server that starts the mail passed will directly pass through the port 25 of the Transmission Control Protocol / Internet Protocol.
The target SMTP server communicates. If the username of the recipient email address is used in the target server
If the account is matched, the original email will eventually transfer to the server, and wait for the recipient to charge through the client.
If the SMTP server passed by the mail cannot communicate directly with the target server, the SMTP protocol can provide
Or multiple relay SMTP servers transmit mail mechanisms. The relay server will receive the original mail, then try to pass it
To the target server, or redirect to another relay server. This process will be repeated until the message is delivered to the target server.
Or exceed the specified timeout.
Setting SMTP in Windows 2000 Starting from Microsoft Windows NT?, The SMTP service has always been a component of the Internet information service. Since the SMTP service is mainly used in Duwamish Online to handle capacity relatively small-to-send emails (for confirmation orders), this feature is not necessary to use a computer in the initial stage of business. Finally, we decided to put the SMTP service on the order processing server, which is connected to the external Internet segment.
Below is the steps for setting up an SMTP service for the Duwamish Online Web site.
Configuring SMTP services If the SMTP service is installed on the host connected to the Internet, and the firewall facing the Internet does not prevent the SMTP communication access port 25, the default settings of the SMTP service should be able to pass all other emails. However, there may still have some security settings to be considered for SMTP servers. Most of these settings can be changed through the Internet Service Manager management console.
To start the IIS Management Console, do the following:
From the start menu, point to Programs / Management Tools. Click Internet Service Manager to start the management console. To set up a server logging, do the following:
Expand the directory tree in the left pane of the Internet Information Services dialog. Right-click the default SMTP virtual server and select Properties. Click General tab in the Properties dialog. Check the Enable Logging check box for this server. This property is not enabled by default. Select the preferred log file format. The default is set to W3C expansion log file format. Click on the property button next to the drop-down menu next to the log file format. If necessary, adjust the schedule and file name of the log file flip. Click the Extended Properties tab. Select any items that are interested, click OK. Note In order to limit the size of the log file, there should not be too much item. Some items that may be useful here: Date, time, customer IP address, user name, service name, method, send byte, and number of received bytes. To set access control, do the following:
Click the Access tab in the Properties dialog. Single click the repeater button to control the email to the computer of the SMTP server. Click Add in the Relay Limit dialog box. In the Computer dialog box, enter the computer IP address that allows email through the SMTP server relay. Click OK Application Change. Note If the message is sent from the same computer to the SMTP server, the default setting for relay rights will work well. However, if the message is issued from another computer, you need to add the IP address or domain name of the computer to the permissions list to make the relay work normally.
Specifies the smart host to relay if the SMTP server is located after blocking all direct SMTP communication (via port 25), you need to find a smart host that allows multiple SMTP messages to the Internet.
Fundamentally, the smart host can be another SMTP server with email relay permissions, which transfers the message directly from other internal SMTP servers to the Internet. Therefore, the smart host should be able to connect the internal network and Internet at the same time, so that you can act as an email gateway.
After identifying the smart host on the network, you can set the SMTP server.
To set a SMTP server, do the following:
Click the Pass tab in the Properties dialog box, then click the Advanced button to open the Advanced Pass dialog. Type a domain name (FQDN) that is fully qualified in the Smart Host field. Or enter the IP address of the smart host and add [and] before and after, such as "[10.10.10.1]. [] Helps accelerate the DNS query process. Click OK to complete the above changes. Verify that the SMTP service has a variety of ways to verify that the SMTP service is working properly.
Test by Email Clients First, you can choose to use standard Internet email clients (such as Microsoft Outlook® Express) to perform quick validation. Find a location that can specify the email (SMTP) server, change it to a new SMTP server domain name. Send a test message to the usual email address, verify that the send is normal.
You can also write a simple email text file that complies with SMTP specifications (RFC 822) by collecting directory. Below is the sample text file content entered in Notepad:
From: myname@mydomain.com ketotto: someone@somain.com.comsubject: Testing
This is the test message body body.
Simply copy or move the text file to the charged directory where the SMTP is installed. (The default path should be "root: / inetpub / mailroot / pickup".) The SMTP service will regularly check the directory and attempt to send all the emails found in the directory. Verify that the test message can be received in the target inbox.
For more information on the RFC 822 specification that correctly formats the mail, see the RFC 822 mail format.
Testing the SMTP service with the CDO is another way of using the Windows 2000 Collaboration Data Object (CDO) to write a simple Microsoft VisualBasic? Scripting Edition (vbscript) script. CDO for Windows 2000 (a.k.a. CDO 2.0 or CDOSYS.DLL) is a set of collaborative components for simplifying Internet mail creation or processing. With CDO, developers do not have to write their own SMTP communication code, but use CDO to send and receive messages that use SMTP protocols, or receive mail by local collection. For more information, see related articles for CDO for Windows 2000.
Below is an example of a VBScript, explaining how to use the CDO to pass the email through the SMTP service:
Set msg = wscript.createObject ("cdo.message") msg.from = "myname@mydomain.com" msg.to = "some00@somain.com" msg.subject = "Testing" msg.textbody = "this is a Test Message Body. "
Msg.configuration.fields ("http://schemas.microsoft.com/cdpo/configuration/smtpserver) =" smtpser.mydomain.com "
Msg.configuration.fields ("http://schemas.microsoft.com/cdpo/configuration/sendusing") = 2
Msg.configuration.fields.Updatemsg.send
The top five lines of the above code example creates a CDO object and specifies the basic information of the message.
The next two lines of code use the CDO Configuration object to set the field values set for each configuration. Each field consists of two parts: namespace prefix (such as "http://schemas.microsoft.com/cdo/configuration/" and local names (such as "SMTPSERVER").
This mechanism is based on the namespace recommended standard (http://www.w3c.org/tr/rec-xml-names/), which is mainly used to provide consistency, and promote other related versions. Compatibility of CDO components.
Field "SMTPServer" Specifies the domain name (or IP address) of the SMTP server, and the field "sendusing" definition should be sent to the SMTP server directly through the network. The value of the latter field is set to 2, indicating that the message is sent to the specified SMTP server via the network.
Last two lines of code update configuration settings and start mailing.
This method using CDO components may be more than validating SMTP services. However, this script has proven to be useful for other system management tasks. For example, when some system counters exceed the specified threshold, the script can be used in the Performance Logs and Alerts program written for email notifications.
Identify failures of failure cannot pass email (eg, user name or email address error), regardless of why the email (for example, the username or email address error) will be redirected to the dead letter directory. The default location of the dead letter catalog should be "root: / inetpub / mailroot / badmail". Check the contents of the rejection email and look for any specific error message. If possible, correct the error and reissue emails again through one of the passwords discussed above. In addition to the dead letter directory, emails can also save a specified time in the queue directory. (The specified method for this setting is: Adjust the station heavy trial interval in the delivery tab of the default SMTP Virtual Server Properties dialog.) If the network is not transferred immediately because the network is busy or the network connection is disconnected, the mail will be stored in the queue. In the directory, send it again according to the specified interval. If the SMTP will give up the pass after several pass attempts, the message will eventually move to the dead letter directory.