回车换行都会有影响,可以用foxmail,查看邮件源码来调试。
点击(此处)折叠或打开
-
fprintf(pFile, "From:%s\n",smtp.szSender);
-
fprintf(pFile, "To:%s\n",smtp.szRecver);
-
fprintf(pFile, "Subject:%s\n",smtp.szTitle);
-
fprintf(pFile, "MIME-Version: 1.0\n");
-
fprintf(pFile, "Content-Type:multipart/mixed;\n"); //添加附件必须!可以看下MIME协议
-
fprintf(pFile, " boundary=\"=====001_NextPart167448323667_=====\"\n"); //邮件正文开始
-
-
fprintf(pFile, "\r\n");
-
fprintf(pFile, "--=====001_NextPart167448323667_=====\n"); //段开始标识
-
fprintf(pFile, "Content-Type:multipart/alternative;\n"); //文本和超文本,添加此标识
-
fprintf(pFile, " boundary=\"=====002_NextPart167448323667_=====\"\r\n"); //boundary 有开始也要有结束
-
-
fprintf(pFile, "--=====002_NextPart167448323667_=====\n");
-
fprintf(pFile, "Content-Type: text/plain; charset=\"UTF-8\"\n");
-
fprintf(pFile, "Content-Transfer-Encoding: base64\r\n");
-
-
sprintf(buf_str,"Hello!\n This e-mail is come from montion detection of IPNC.\n");
-
-
base64Encode(buf_str,buf_out,strlen(buf_str) + 1,&len_out);
-
fprintf(pFile, "%s\r\n",buf_out);
-
fprintf(pFile, "--=====002_NextPart167448323667_=====--\r\n");
-
-
- fprintf(pFile, "--=====001_NextPart167448323667_=====\n");
-
fprintf(pFile, "Content-Transfer-Encoding: base64\n");
-
fprintf(pFile, "Content-Type:image/jpeg; name=\"%s\"\n",pt);
-
fprintf(pFile, "Content-Disposition: attachment; filename=%s\r\n\r\n",pt);
-
-
base64Encode_file(in, pFile, ufile_size);
-
-
- fprintf(pFile, "\n--=====001_NextPart167448323667_=====--\r\n\r\n"); // 邮件结束