[英](Qt) Curl uploading to smtp sends an empty email
我使用的是Qt,最近我使用gmail開發了一個類似的應用程序。 現在,我想將電子郵件從Outlook發送到gmail。 編輯:我只是嘗試使用應用程序密碼從Outlook發送到Outlook,但是Outlook收件箱中的電子郵件仍然為空... 結束編輯這是我的代碼:
if(file.open(QIODevice::ReadWrite)){ //Writes in the msg.txt
QTextStream stream(&file);
stream << "From: \"Me\" <xxxxxxxxxx@outlook.com>" << endl;
stream << "To: \"Me\" <xxxxxxxxxxxx@gmail.com>" << endl;
stream << "Subject: Subject" << endl;
stream << msg << endl; //msg is just a QString variable
}
QString cmd = "ccurl smtp://smtp-mail.outlook.com:587 -v --mail-from \"xxxxxxxxxxxx@outlook.com\" --mail-rcpt \"xxxxxxxxxxxx@gmail.com\" --ssl -u xxxxxxxxxxxxxx@outlook.com:xxxxxxxxxxxxxx -T \"msg.txt\" -k --anyauth --insecure & pause";
const std::string s = cmd.toStdString();
const char* ccmd = s.c_str();
system(ccmd);
暫停僅用於測試目的。 另外,我的.exe名為“ ccurl”,並且出現的控制台不會引發任何錯誤。 我確實收到了一封電子郵件,但只說了(空)
---
Email checked by avast....
謝謝你的幫助!
PS。 不要告訴我改用libcurl
您在標題的末尾和郵件正文的開頭之間缺少空行。 沒有它,消息的其余部分將被解釋為仍然是標頭的一部分。
同樣, endl
也不會有任何理由強制在流中進行刷新,這會在處理文件時降低性能。 只需使用\\n
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.