小编abd*_*doe的帖子

Smtp客户端 - 来自和不发送

我有一个用c ++构建的smtp客户端,我可以将电子邮件发送到我的测试mailtrap帐户.标题已发送,电子邮件即将到达.

我的问题是,从/到指示的字段是空的 - 如屏幕截图所示

在此输入图像描述

我正在发送标题

write_command("MAIL FROM: <foo@bar.de>");
write_command("RCPT TO: <foo@bar.de>");
Run Code Online (Sandbox Code Playgroud)

我用我的Smtp客户端的完整代码做了一个要点

https://gist.github.com/anonymous/7bb13de7f044bcb5d07d0e6a9d991ea9

我是从我的main()功能中调用它的

 Smtp smtp_client = Smtp();
 smtp_client.new_connection("smtp.mailtrap.io", 25);
 smtp_client.auth_login("username", "password");
 smtp_client.sendmail();
 smtp_client.close_connection();
Run Code Online (Sandbox Code Playgroud)

谢谢你的表情

c++ email smtp smtpclient

5
推荐指数
1
解决办法
375
查看次数

来自fn的Rust返回结果错误

我希望此函数返回错误结果:

fn get_result() -> Result<String, std::io::Error> {
     // Ok(String::from("foo")) <- works fine
     Result::Err(String::from("foo"))
}
Run Code Online (Sandbox Code Playgroud)

错误信息

error[E0308]: mismatched types
 --> src/main.rs:3:17
  |
3 |     Result::Err(String::from("foo"))
  |                 ^^^^^^^^^^^^^^^^^^^ expected struct `std::io::Error`, found struct `std::string::String`
  |
  = note: expected type `std::io::Error`
             found type `std::string::String`
Run Code Online (Sandbox Code Playgroud)

我很困惑如何在使用预期的结构时打印出错误消息.

rust rust-result

3
推荐指数
2
解决办法
5138
查看次数

返回时c ++ win32api值编码损坏

我几乎不知道如何描述这种行为,所以这可能是我无法自己找到答案的原因 - 我根本就不知道如何命名这个问题.所以,如果标题是误导性的,或者问题在某种程度上是错误的,请耐心等待,但是这里来了

我有一个类方法,我打开一个文件并获取文件名:

OPENFILENAME GuiUtils::ChooseFileDialog(HWND hwnd)
{
    OPENFILENAME ofn;
    char szFile[260];
    ZeroMemory(&ofn, sizeof(ofn));
    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = hwnd;
    ofn.lpstrFile = (LPWSTR)szFile;
    ofn.lpstrFile[0] = '\0';
    ofn.nMaxFile = sizeof(szFile);
    ofn.nFilterIndex = 1;
    ofn.lpstrFileTitle = NULL;
    ofn.nMaxFileTitle = 0;
    ofn.lpstrFilter = TEXT("Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0");
    ofn.lpstrInitialDir = NULL;
    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
    HANDLE hf;

    // Display the Open dialog box. 
    if (GetOpenFileName(&ofn) == TRUE)
    {
        hf = CreateFile(ofn.lpstrFile,
            GENERIC_READ,
            0,
            (LPSECURITY_ATTRIBUTES)NULL,
            OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL,
            (HANDLE)NULL);
    }
    return ofn;
}
Run Code Online (Sandbox Code Playgroud)

当我看到 …

c++ winapi encoding callback

0
推荐指数
1
解决办法
107
查看次数

如何从 std::string::String 中删除换行符/换行符?

我找不到可以做到这一点的东西。到目前为止,我所拥有的仅适用于空白:

pub fn minify(&self) {
    println!("Minify task started ... ");
    let mut string_iter = self.mystring.split_whitespace();
    for strings in string_iter {
        println!("{}", strings);
    }
}
Run Code Online (Sandbox Code Playgroud)

mystring 是这样的:

let mystring = "p {
                  text-align: center;
                  color: red;
                } ";
Run Code Online (Sandbox Code Playgroud)

string split linefeed rust

0
推荐指数
1
解决办法
3192
查看次数

标签 统计

c++ ×2

rust ×2

callback ×1

email ×1

encoding ×1

linefeed ×1

rust-result ×1

smtp ×1

smtpclient ×1

split ×1

string ×1

winapi ×1