linux下基于smtp协议的C++客户端debug经验
来源:互联网 发布:中国式过马路看法数据 编辑:程序博客网 时间:2024/06/01 08:06
我所使用的是Ubuntu下saslauthd+ postfix + dovecot搭建的环境。
1.解决mail.log出现的warning: SASL authentication failure: cannot connect to saslauthd
原因:postfix没有找到saslauthd的工作目录,由于postfix的工作目录默认在/var/spool/postfix/var/run/saslauthd中;而saslauthd默认的工作目录为/var/run/saslauthd中,从而导致postfix无法连接saslauthd服务。
解决办法:
打开 saslauthd的配置文件
sudo vim /etc/default/saslauthd
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd"
如果没有这个路径,使用mkdir命令创建就行了。
然后再创建一个符号链接:
sudo ln -s /var/spool/postfix/var/run/saslauthd/ /var/run/saslauthd
测试:
重启:
sudo /etc/init.d/saslauthd restart
添加用户
sudo adduser postfix sasl
testsaslauthd -u username -p password(username 替换为你的用户名, password:替换为你的密码)
输出0: OK "Success."则代表成功
2.解决: postfix/smtp[19420] :disconnect from localhost[127.0.0.1]
打开你的postfix的配置文件:
#你所用的smtp服务器,记得要在在服务器中开启smtp
sudo vim /etc/postfix/main.cf
然后修改或者添加下面的内容:
#你所用的smtp服务器,记得要在在服务器中开启smtp
myhostname = smtp.qq.com
#你用的smtp服务的域名
mydomain = qq.com
然后重启postfix服务:
sudo /etc/init.d/postfix restart
就可以了。
3.解决:在输入auth login之后出现error:535 authentication failed
第一种:
可能就是你的右键客户端没有开启smtp服务。
我用来测试的是smtp.163.com。只要登陆网易邮箱,然后设置一下就行了。
详细请看:http://help.163.com/09/1223/14/5R7P6CJ600753VB8.html?servCode=6010376
第二种:
可能就是你输入的不是你的smtp的独立密码,以163的邮箱为例,在你设置的时候它会要求你设置一个独立的密码。
第三种:
可能是最麻烦的一种可能:你没有安装postfix,或者安装了postfix,没有开启sasl和pop3服务。
首先:你要安装这两个软件:
我的是Ubuntu版本:
apt-get install sasl2-bin postfix dovecot-pop3d
在安装了postfix之后,需要配置postfix
下列命令和直接修改/etc/postfix/main.cf是一样的。
sudo postconf -e 'smtpd_sasl_type = dovecot'
sudo postconf -e 'smtpd_sasl_path = private/auth-client'
sudo postconf -e 'smtpd_sasl_local_domain ='
sudo postconf -e 'smtpd_sasl_security_options = noanonymous'
sudo postconf -e 'broken_sasl_auth_clients = yes'
sudo postconf -e 'smtpd_sasl_auth_enable = yes'
sudo postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
sudo postconf -e 'inet_interfaces = all'
sudo postconf -e 'smtpd_sasl_path = private/auth-client'
sudo postconf -e 'smtpd_sasl_local_domain ='
sudo postconf -e 'smtpd_sasl_security_options = noanonymous'
sudo postconf -e 'broken_sasl_auth_clients = yes'
sudo postconf -e 'smtpd_sasl_auth_enable = yes'
sudo postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
sudo postconf -e 'inet_interfaces = all'
sudo postconf -e 'home_mailbox = Maildir/'
然后在main.cf 中的mydestination中添加下列几个地址: example.com, mail.example.com, localhost.example.com, localhost
修改 saslauthd 配置文件:
sudo vim /etc/default/saslauthd
将START设为yes
START = yes
重启sasl:
sudo /etc/init.d/saslauthd restart
然后修改etc/dovecot/dovecot.conf,在最后添加下面内容:
mail_location = maildir:~/Maildir
#postfix中设置了mailbox类型为maildir,这是对应的设置。
disable_plaintext_auth = no
#默认情况下,dovecot是不允许plaintext类型的认证
输入命令:
sudo dovecot reload
重新加载配置,让你的配置生效
最后重启postfix:
sudo /etc/init.d/postfix restart
测试:
telnet localhost 25
ehlo lcal
auth login
4.解决:操作正常,smtp返回正常,但是收不到邮件
smtp一般都会对邮件的中文字数有限制来防止垃圾邮件,因此要有一定字数的中文才能发送。
0 0
- linux下基于smtp协议的C++客户端debug经验
- linux下基于SMTP协议的C++邮件客户端
- linux下C语言编程日志(1):基于TCP协议的服务器/客户端程序
- linux下用C编写的基于smtp的带附件邮件发送程序
- linux下用C编写的基于smtp的邮件发送程序
- linux下用C编写的基于smtp的邮件发送程序
- linux下用C编写的基于smtp的邮件发送程序
- 基于raw smtp用php实现简易的smtp客户端
- 基于SMTP的邮件发送客户端
- 基于C#平台下利用POP3和SMTP协议的邮件归档系统
- SMTP协议初探(二)----linux下c编程实现发邮件
- SMTP协议初探(二)----linux下c编程实现发邮件
- 基于http协议的C语言客户端代码
- Linux UDP下C语言实现TFTP协议客户端
- Linux UDP下C语言实现TFTP协议客户端 .
- Linux下C语言编写基于命令行的FTP客户端与服务端
- Linux下基于UDP协议的C/S通信编程笔记
- java网络编程三:基于SMTP的邮件发送客户端
- 一个 IT 青年编程四年的感悟
- Java进程监控与分析
- PostgreSQL partial/sub commit within function
- 模式识别之身份证识别
- 找出一个二维数组中的“鞍点”,即该位置上的元素在该行中 最大,在该列中最小(也可能没有“鞍点”),打印有关信息。(提示:注意特 殊情况:没鞍点或多个鞍点)
- linux下基于smtp协议的C++客户端debug经验
- use PostgreSQL async Notification as a chat group
- 日经春秋 20151014
- 交换排序——快速排序
- Scala的安装
- 第117讲:Hadoop集群之安装IP配置、Slaves、namenode和secondarynamenode的配置学习笔记
- 相同的字符串常量是可以共享内存的
- action请求参数决定结果
- Android数据解析获取JSONObject的key值-Iterator应用