Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sendmail: Reached EOF while searching for end marker #2683

Open
SelimOzel opened this issue Aug 9, 2022 · 3 comments
Open

Sendmail: Reached EOF while searching for end marker #2683

SelimOzel opened this issue Aug 9, 2022 · 3 comments

Comments

@SelimOzel
Copy link

SelimOzel commented Aug 9, 2022

I am using vibe-d on Ubuntu/AWS-EC2 and trying to send an email over it. The script is simple and is from the vibe-d example. However, it gets stuck for a long time and throws an error message.

Code:

// D
import std.stdio;

// Third party
import vibe.core.log;
import vibe.mail.smtp;

void main()
{
writeln("Send mail.");
auto settings = new SMTPClientSettings("smtpout.secureserver.net", 465);
settings.authType = SMTPAuthType.plain;
settings.username = "mail@server.com";
settings.password = "password";
settings.connectionType = SMTPConnectionType.startTLS;

auto mail = new Mail;
mail.headers["Date"] = Clock.currTime(PosixTimeZone.getTimeZone("America/New_York")).toRFC822DateTimeString();
mail.headers["From"] = "<mail@server.com>";
mail.headers["To"] = "<mail@server.com>";
mail.headers["Subject"] = "Testmail";
mail.headers["Content-Type"] = "text/plain;charset=utf-8";
mail.bodyText = "Hello, World!";

logInfo("Sending mail...");
sendMail(settings, mail);
logInfo("done.");	
}

Error:

Running ./sendmail
Send mail.
[main(----) INF] Sending mail...
object.Exception@../../.dub/packages/vibe-d-0.9.5/vibe-d/stream/vibe/stream/operations.d(375): Reached EOF while searching for end marker.
----------------
/home/ubuntu/dlang/dmd-2.091.0/linux/bin64/../../src/phobos/std/exception.d:516 pure @safe void std.exception.bailOut!(Exception).bailOut(immutable(char)[], ulong, scope const(char)[]) [0x558a096b0802]
/home/ubuntu/dlang/dmd-2.091.0/linux/bin64/../../src/phobos/std/exception.d:437 pure @safe bool std.exception.enforce!().enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], ulong) [0x558a096b077e]
../../.dub/packages/vibe-d-0.9.5/vibe-d/stream/vibe/stream/operations.d:375 @safe void vibe.stream.operations.readUntilSmall!(vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy).readUntilSmall(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, ref vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, const(ubyte[]), ulong) [0x558a096bde67]
../../.dub/packages/vibe-d-0.9.5/vibe-d/stream/vibe/stream/operations.d:142 @safe void vibe.stream.operations.readUntil!(vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy).readUntil(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, ref vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, const(ubyte[]), ulong) [0x558a096bdd3b]
../../.dub/packages/vibe-d-0.9.5/vibe-d/stream/vibe/stream/operations.d:56 @safe void vibe.stream.operations.readLine!(vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy).readLine(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, ref vibe.utils.array.AllocAppender!(ubyte[], ubyte).AllocAppender, ulong, immutable(char)[]) [0x558a096bdc60]
../../.dub/packages/vibe-d-0.9.5/vibe-d/stream/vibe/stream/operations.d:41 @safe ubyte[] vibe.stream.operations.readLine!(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy).readLine(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, ulong, immutable(char)[], stdx.allocator.IAllocator) [0x558a096bd318]
../../.dub/packages/vibe-d-0.9.5/vibe-d/mail/vibe/mail/smtp.d:259 @trusted immutable(char)[] vibe.mail.smtp.expectStatus!(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy).expectStatus(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, int, immutable(char)[]).__lambda4() [0x558a096bd116]
../../.dub/packages/vibe-d-0.9.5/vibe-d/mail/vibe/mail/smtp.d:259 @safe void vibe.mail.smtp.expectStatus!(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy).expectStatus(vibe.internal.interfaceproxy.InterfaceProxy!(vibe.core.stream.Stream).InterfaceProxy, int, immutable(char)[]) [0x558a096bcf96]
../../.dub/packages/vibe-d-0.9.5/vibe-d/mail/vibe/mail/smtp.d:146 @safe void vibe.mail.smtp.sendMail(const(vibe.mail.smtp.SMTPClientSettings), vibe.mail.smtp.Mail) [0x558a096af23b]
source/app.d:25 _Dmain [0x558a096ac4ba]
Program exited with code 1
@SelimOzel
Copy link
Author

SelimOzel commented Aug 9, 2022

To give more context, smtpout.secureserver.net is Go Daddy's web server and I'm trying to send an e-mail to myself via my account.

@s-ludwig
Copy link
Member

s-ludwig commented Aug 9, 2022

The only likely cause that I can see is the server expecting a TLS connection, but an unencrypted one has been established. In that case you could try setting settings.connectionType = SMTPConnectionType.tls.

@SelimOzel
Copy link
Author

I did get a different response when I build/executed the following:

// D
import std.stdio;

// Third party
import vibe.core.log;
import vibe.mail.smtp;

void main()
{
	writeln("Send mail.");
	auto settings = new SMTPClientSettings("smtpout.secureserver.net", 465);
	settings.connectionType = SMTPConnectionType.tls;
	settings.authType = SMTPAuthType.none;
	settings.username = "mail@server.com";
	settings.password = "password";

	auto mail = new Mail;
	mail.headers["From"] = "<mail@server.com>";
	mail.headers["To"] = "<mail@server.com>";
	mail.headers["Subject"] = "Testmail";
	mail.bodyText = "Hello, World!";

	logInfo("Sending mail...");
	sendMail(settings, mail);
	logInfo("done.");	
}

The output is:
object.Exception@../../.dub/packages/vibe-d-0.9.5/vibe-d/tls/vibe/stream/openssl.d(668): Connecting TLS tunnel: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed (337047686)

This sounds like a certificate issue. What's confusing to me is when I run a very similar program in python to send e-mail same way, it works without me mapping any certificate files. Is vibe-d different in that sense?

Best wishes,
Selim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants