C language code for sending emails in Linux-general Linux technology-Linux programming and kernel information. The following is a detailed description. Currently, many users automatically obtain the ip address instead of the fixed ip address. Now, as a simple program, they automatically send his ip address to the specified email address every time they access the internet. The implementation is very simple (of course, the premise is that you have the corresponding permissions,: D), by calling system (), put the program path in/etc/rc. local, so that each call can be started. Use ifconfig to get the ip address, write it to a temporary file, read the file content to the buffer, and send it as the email body to the specified email. Taking the 163.com smtp server as an example, the current smtp servers are all added with the verification function (different server verification methods, sina verification is different, the specific verification method is not studied ), the communication process is as follows:
[Root @ localhost root] # telnet smtp.163.com 25
Trying 202.108.44.170...
Connected to smtp.163.com.
Escape character is '^]'.
220 Coremail SMTP (Anti Spam) System (163com [20030606])
Ehlo smtp.163.com
250-1900001.170
250-PIPELINING
250-AUTH LOGIN PLAIN NTLM
250-AUTH = LOGIN PLAIN NTLM
250 8 BITMIME
Auth login
334 VXNlcm5hbWU6
Xxxxxx (base64 encoded user name)
334 UGFzc3dvcmQ6
Xxxxx (base64 encoded password)
235 Authentication successful
Mail from: gyfxlt8.go@163.com
250 OK
Rcpt to: gymiles@sohu.com
250 OK
Data
354 End data.
Test
.
250 OK: queued as IMA5dQQvoEEGyE4C. 1
Quit
221 Bye
Connection closed by foreign host.
Smtp server return value table
500 Incorrect email address
501 Incorrect Parameter format
502 commands cannot be implemented
503 SMTP verification is required for the server
504 command parameters cannot be implemented
421 service not ready, disable Transmission Channel
450 the email operation is not completed and the mailbox is unavailable (for example, the mailbox is busy)
550 the requested email operation is incomplete and the email address is unavailable (for example, the email address is not found or cannot be accessed)
451 discard required operations; errors occurred during handling
551 users are not local. Please try
452 the system storage is insufficient and the required operations are not performed
552 excessive storage allocation, required operations not performed
553 the mailbox name is unavailable and the required operation is not performed (for example, the mailbox format is incorrect)
432 requires a password Conversion
534 authentication mechanism is too simple
538 encryption is required for the authentication mechanism currently requested
454 temporary authentication failed
530 authentication required
220 Service ready
250 the required email operation is completed
251 the user is not local and will forward
354 start email input, ended.
221 disable transmission channels
334 Server Response verification Base64 string
235 Verification Successful
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.