Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ufront/mail/Email.hx
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ class Email {
If no such header exists, it will return `null`.
**/
public function getHeader( name ):Null<String> {
if ( headers.exists(name) )
return headers.get( name )[0];
else
if ( headers.exists(name) ) {
var h = headers.get( name );
return h[0];
}else{
return null;
}
}

/**
Expand Down
15 changes: 9 additions & 6 deletions src/ufront/mailer/SmtpMailer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,25 @@ class SmtpMailer implements UFMailer {
throw ConnectionError(host,port);
}

var esmtp = false;
var supportLoginAuth = false;

// get server init line
var ret = StringTools.trim(cnx.input.readLine());
var esmtp = ret.indexOf("ESMTP") >= 0;


while (StringTools.startsWith(ret, "220-")) {
ret = StringTools.trim(cnx.input.readLine());
}

//see https://en.wikipedia.org/wiki/Extended_SMTP
cnx.write( "EHLO " + Host.localhost() + "\r\n");
ret = StringTools.trim(cnx.input.readLine());
if ( ret.substr(0, 3) == "250" ){
esmtp = true;
}


if ( esmtp ) { //if server support extensions
//EHLO
cnx.write( "EHLO " + Host.localhost() + "\r\n");
ret = "";

do {
ret = StringTools.trim(cnx.input.readLine());
if( ret.substr(0,3) != "250" ){
Expand Down