Linux system send email to the C language code

Source: Internet
Author: User
Tags auth linux

Now many users are automatically access to IP, rather than fixed, now make a simple program, every time he surfed the Internet, his IP automatically sent me the specified email. The implementation is simple (of course, if you have the appropriate permissions,:D), by invoking system (), the program path is placed in/etc/rc.local so that the call can be started each time. Use ifconfig to obtain IP, and write to a temporary file, and then read the contents of the file to the buffer, as the email body sent to the specified email. Take 163.com SMTP server as an example, now the SMTP server has joined the authentication function (different server authentication method is different, Sina authentication is different, the specific authentication method is not studied), the communication process is this:

[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-192.168.1.170
250-PIPELINING
250-AUTH LOGIN PLAIN NTLM
250-AUTH=LOGIN PLAIN NTLM
250 8BITMIME
auth login
334 VXNlcm5hbWU6
xxxxxx(base64编码过的用户名)
334 UGFzc3dvcmQ6
xxxxx(base64编码过的密码)
235 Authentication successful
mail from:gyfxlt8.go@163.com
250 Ok
rcpt to:gymiles@sohu.com
250 Ok
data
354 End data with .
test
.
250 Ok: queued as IMA5dQQvoEEGyE4C.1
quit
221 Bye
Connection closed by foreign host.

SMTP Server return value table

500 邮箱地址错误
501 参数格式错误
502 命令不可实现
503 服务器需要SMTP验证
504 命令参数不可实现
421 服务未就绪,关闭传输信道
450 要求的邮件操作未完成,邮箱不可用(例如,邮箱忙)
550 要求的邮件操作未完成,邮箱不可用(例如,邮箱未找到,或不可访问)
451 放弃要求的操作;处理过程中出错
551 用户非本地,请尝试
452 系统存储不足,要求的操作未执行
552 过量的存储分配,要求的操作未执行
553 邮箱名不可用,要求的操作未执行(例如邮箱格式错误)
432 需要一个密码转换
534 认证机制过于简单
538 当前请求的认证机制需要加密
454 临时认证失败
530 需要认证
220 服务就绪
250 要求的邮件操作完成
251 用户非本地,将转发向
354 开始邮件输入,以.结束
221 服务关闭传输信道
334 服务器响应验证Base64字符串
235 验证成功



Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.