Open
Description
I tried this code:
use lettre::message::header::ContentType;
use lettre::message::Mailbox;
use lettre::transport::smtp::authentication::Credentials;
use lettre::{Message, SmtpTransport, Transport};
pub fn send_mail(){
let email = Message::builder()
.from(Mailbox::new(Some("NoBody".to_owned()), "[email protected]".parse().unwrap()))
.to(Mailbox::new(Some("Jake".to_owned()), "[email protected]".parse().unwrap()))
.subject("Happy new year")
.header(ContentType::TEXT_PLAIN)
.body(String::from("Be happy!"))
.unwrap();
let creds = Credentials::new("********".to_owned(), "********".to_owned());
let mailer = SmtpTransport::relay("smtp.gmail.com")
.unwrap()
.credentials(creds)
.build();
match mailer.send(&email) {
Ok(_) => println!("Email sent successfully!"),
Err(e) => panic!("Could not send email: {e:?}"),
}
println!("It maybe was sent, god knows lol")
}
I expected to see this happen: I expected this just to compile, and it does if I remove send_mail();
from main.
Instead, this happened:
Running `C:\Users\yasus\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name super_mailer --edition=2024 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=195 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg "cfg(feature, values())" -C metadata=bcd1550eb5a49f64 --out-dir C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps -C incremental=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\incremental -L dependency=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps --extern crossterm=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps\libcrossterm-a2896138aba4cbca.rlib --extern lettre=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps\liblettre-2e0a5dca77af8408.rlib -L native=C:\Users\yasus\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\windows_x86_64_msvc-0.52.6\lib -L native=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\build\stacker-215710db05c75678\out -L native=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\build\psm-a3614098bb21b20f\out`
error: linking with `link.exe` failed: exit code: 0xc0000409
|
= note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.44.35207\\bin\\HostX64\\x64\\link.exe" "/NOLOGO" "C:\\Users\\yasus\\AppData\\Local\\Temp\\rustcK1uMhh\\symbols.o" "<38 object files omitted>" "C:\\Users\\yasus\\OneDrive\\Документы\\Projects\\super_mailer\\target\\debug\\deps/{liblettre-2e0a5dca77af8408.rlib,libhostname-eed90ed76500f9f5.rlib,libwindows_link-c671848fa1bbbd80.rlib,libfastrand-4e87811bf4d38564.rlib,libquoted_printable-e499ff83f5f94390.rlib,libnom-a4cc784d0a98a953.rlib,liburl-4fb24042a3ba778e.rlib,libform_urlencoded-b931625d83505a8e.rlib,libpercent_encoding-fdfa14da79359144.rlib,libsocket2-a2adbdc0a9f55cf4.rlib,libwindows_sys-bff11553e8e7a421.rlib,libnative_tls-3cf9365914e8aefb.rlib,libschannel-a7228c3899879f20.rlib,libchumsky-331187dd4dddd41a.rlib,libstacker-8ddc4a9035316951.rlib,libpsm-1c09dfc7131f4d00.rlib,libwindows_sys-287eedbeb1eb43b2.rlib,liblibc-ada8e62f5a602c05.rlib,libhashbrown-589884e71e0bff27.rlib,libahash-c033550c677a7570.rlib,libonce_cell-e592c66a18823b6b.rlib,libzerocopy-e8ac166101d36229.rlib,liballocator_api2-ce4fbb7a8d6c8346.rlib,libhttpdate-b0862c2ab3b36b1b.rlib,libmime-3bb1031fd8f3be52.rlib,libemail_encoding-1e31fd9bcc551c3d.rlib,libmemchr-abe59992233c7b36.rlib,libbase64-745cbf9310fbabea.rlib,libidna-58e619c56e934a69.rlib,libutf8_iter-219f97cfa0cacdb0.rlib,libidna_adapter-1327038b6594ccd1.rlib,libicu_properties-9854c57e7ea86a67.rlib,libicu_properties_data-029ce1b7a571026e.rlib,libicu_normalizer-0e10a281e72575a4.rlib,libicu_normalizer_data-670c728bd730785e.rlib,libicu_collections-c104c53aa0681b8b.rlib,libpotential_utf-e6a24eacb0e4e43f.rlib,libicu_provider-b96653067541a01e.rlib,libicu_locale_core-8bf89ee76ecf4fbe.rlib,libtinystr-b9bb01c1c852905e.rlib,liblitemap-c41745663806bcdd.rlib,libwriteable-be1dd466d0d1abe7.rlib,libzerovec-42872e1af5841112.rlib,libzerotrie-49512dfa4cf71917.rlib,libyoke-0dda10b7ba2a0385.rlib,libstable_deref_trait-a0841b90f24d7543.rlib,libzerofrom-c4d21e69467e00c4.rlib,libemail_address-520f395cca57689f.rlib,libcrossterm-a2896138aba4cbca.rlib,libbitflags-469cfbc09bafbbbf.rlib,libparking_lot-7565345fc200346e.rlib,libparking_lot_core-f73536215fd7608a.rlib,libwindows_targets-832063ff1bd69dfe.rlib,libcfg_if-211458c1ab1808ad.rlib,libsmallvec-8852ba454fa13744.rlib,liblock_api-cb8004615e3f4ee2.rlib,libscopeguard-0ea152da1c635355.rlib,libcrossterm_winapi-9e15ad17dc4dfcd8.rlib,libwinapi-19a4e1f0c3b33500.rlib}.rlib" "<sysroot>\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib/{libstd-*,libpanic_unwind-*,libwindows_targets-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libunwind-*,libcfg_if-*,liballoc-*,librustc_std_workspace_core-*,libcore-*,libcompiler_builtins-*}.rlib" "C:\\Users\\yasus\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib\\windows.0.52.0.lib" "C:\\Users\\yasus\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib\\windows.0.52.0.lib" "legacy_stdio_definitions.lib" "C:\\Users\\yasus\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib\\windows.0.52.0.lib" "advapi32.lib" "cfgmgr32.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "synchronization.lib" "user32.lib" "winspool.lib" "kernel32.lib" "kernel32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:C:\\Users\\yasus\\.cargo\\registry\\src\\index.crates.io-1949cf8c6b5b557f\\windows_x86_64_msvc-0.52.6\\lib" "/LIBPATH:C:\\Users\\yasus\\OneDrive\\Документы\\Projects\\super_mailer\\target\\debug\\build\\stacker-215710db05c75678\\out" "/LIBPATH:C:\\Users\\yasus\\OneDrive\\Документы\\Projects\\super_mailer\\target\\debug\\build\\psm-a3614098bb21b20f\\out" "/OUT:C:\\Users\\yasus\\OneDrive\\Документы\\Projects\\super_mailer\\target\\debug\\deps\\super_mailer.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:<sysroot>\\lib\\rustlib\\etc\\libstd.natvis"
= note: some arguments are omitted. use `--verbose` to show all linker arguments
= note:
note: `link.exe` returned an unexpected error
note: the Visual Studio build tools may need to be repaired using the Visual Studio installer
note: or a necessary component may be missing from the "C++ build tools" workload
error: could not compile `super_mailer` (bin "super_mailer") due to 1 previous error
Caused by:
process didn't exit successfully: `C:\Users\yasus\.rustup\toolchains\stable-x86_64-pc-windows-msvc\bin\rustc.exe --crate-name super_mailer --edition=2024 src\main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=195 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg cfg(docsrs,test) --check-cfg "cfg(feature, values())" -C metadata=bcd1550eb5a49f64 --out-dir C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps -C incremental=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\incremental -L dependency=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps --extern crossterm=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps\libcrossterm-a2896138aba4cbca.rlib --extern lettre=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\deps\liblettre-2e0a5dca77af8408.rlib -L native=C:\Users\yasus\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\windows_x86_64_msvc-0.52.6\lib -L native=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\build\stacker-215710db05c75678\out -L native=C:\Users\yasus\OneDrive\Документы\Projects\super_mailer\target\debug\build\psm-a3614098bb21b20f\out` (exit code: 1)
Meta
rustc --version --verbose
:
rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-pc-windows-msvc
release: 1.87.0
LLVM version: 20.1.1
Backtrace
<N/A>
It also does not crash with higher optimization level. If I add
[profile.dev]
opt-level = 1
In to the .toml it compiles.