如何用C实现发送邮件的功能?

软件和网站开发以及相关技术探讨
回复
头像
gootoo
帖子: 51
注册时间: 2006-07-30 15:31

如何用C实现发送邮件的功能?

#1

帖子 gootoo » 2007-04-23 15:01

如何用C实现发送邮件的功能?
上次由 gootoo 在 2007-04-23 15:02,总共编辑 1 次。
头像
gootoo
帖子: 51
注册时间: 2006-07-30 15:31

#2

帖子 gootoo » 2007-04-23 15:01

谢谢!
skyboy
帖子: 31
注册时间: 2005-10-26 22:18

#3

帖子 skyboy » 2007-04-23 15:37

找相关库
HP nx 6120,
cpu CM 1.5G,
chip 915GM,
memory 512M,
harddisk 40G 5400rpm。

ubuntu 7.04 feisty,
with beryl, etc.
头像
猛将兄
帖子: 2052
注册时间: 2005-10-19 17:33

#4

帖子 猛将兄 » 2007-04-23 18:07

gootoo如果头像是你自己的话,帮你做一个。。。
头像
gootoo
帖子: 51
注册时间: 2006-07-30 15:31

#5

帖子 gootoo » 2007-04-24 12:10

不是我自己。
不好意思了!
netvermin
帖子: 3
注册时间: 2007-04-24 14:18

#6

帖子 netvermin » 2007-04-24 14:57

FILE *fout;
char buf[256];
char *from = "me@163.com";
char *to = "you@163.com";
char *content = "Hello!";

sprintf( buf, "/usr/lib/sendmail -f %s %s", from, to );
fout = popen( buf, "w" );
if ( fout == NULL) return 0;

fprintf( fout, "Return-Path: %s\n", from );
fprintf( fout, "Reply-To: %s\n", from );
fprintf( fout, "From: %s\n", from );
fprintf( fout, "To: %s\n", to );
fprintf( fout, "Subject: %s\n", "Hello" );
fprintf(fout, "MIME-Version: 1.0\n");
fprintf(fout, "Content-Type: text/html; charset=gb2312\n");
fprintf(fout, "Content-Transfer-Encoding: 8bit\n");
fprintf(fout, content);
fprintf(fout, "\n.\n");

pclose( fout );
skyboy
帖子: 31
注册时间: 2005-10-26 22:18

#7

帖子 skyboy » 2007-04-24 15:21

楼上的,如果他没有sendmail呢?

不过,这样大概是最简单的办法了。
HP nx 6120,
cpu CM 1.5G,
chip 915GM,
memory 512M,
harddisk 40G 5400rpm。

ubuntu 7.04 feisty,
with beryl, etc.
skyboy
帖子: 31
注册时间: 2005-10-26 22:18

#8

帖子 skyboy » 2007-04-24 15:23

嗯,想到了,
如果没有sendmail程序的话---





去把sendmail的源码下载下来,
然后稍加改动。 :lol:
HP nx 6120,
cpu CM 1.5G,
chip 915GM,
memory 512M,
harddisk 40G 5400rpm。

ubuntu 7.04 feisty,
with beryl, etc.
头像
feeling
帖子: 175
注册时间: 2006-04-29 20:10
来自: 北京·昌平
联系:

#9

帖子 feeling » 2007-05-08 14:00

还有一个比较简单的做法,就是直接操作SMTP服务器的25端口,具体如下:
1. 建立socket描述符,connect到SMTP服务器的25端口;
2. 往连接句柄上面写数据即可。

你可以手工试一试:
telnet 192.168.*.* 25
然后看看有什么反应 ^_^
人生若只如初见,何事秋风悲画扇?
回复