diff --git a/calexium_lib/mail/send_mail.anubis b/calexium_lib/mail/send_mail.anubis index 49379f9..d5885a0 100644 --- a/calexium_lib/mail/send_mail.anubis +++ b/calexium_lib/mail/send_mail.anubis @@ -244,6 +244,20 @@ define Reply_Result }. The same one for 'MAIL FROM': + +define String + check_email_syntax + ( + String email + ) = + if nth(0, email) is + { + failure then "<>", + success(b) then + if b = '<' then email + else "<" + email + ">" + }. + define Reply_Result send_mail_from @@ -251,9 +265,10 @@ define Reply_Result RWStream conn, String sender ) = - if smtp_send_line(conn,"MAIL FROM:"+sender) is + with rfc_sender = check_email_syntax(sender), + if smtp_send_line(conn,"MAIL FROM:"+rfc_sender) is { - failure then logError(send_mail_log, "error sending 'MAIL FROM:" + sender + "'"); error, + failure then logError(send_mail_log, "error sending 'MAIL FROM:" + rfc_sender + "'"); error, success(_) then receive_reply(conn) }. @@ -263,11 +278,12 @@ define Reply_Result send_recipient ( RWStream conn, - String recipient, + String recipient, ) = - if smtp_send_line(conn,"RCPT TO:<"+recipient+">") is + with rfc_recipient = check_email_syntax(recipient), + if smtp_send_line(conn,"RCPT TO:"+rfc_recipient) is { - failure then logError(send_mail_log, "error sending 'RCPT TO:<"+recipient+">'"); error, + failure then logError(send_mail_log, "error sending 'RCPT TO:"+rfc_recipient+"'"); error, success(_) then receive_reply(conn) }. @@ -400,7 +416,7 @@ define SendMailResult Bool enhanced_status )= - with plain_str = "AUTH PLAIN "+ to_string(base64_encode(to_byte_array(login)+ + with plain_str = "AUTH PLAIN "+ to_string(base64_encode(to_byte_array("")+ constant_byte_array(1,0)+ to_byte_array(login)+ constant_byte_array(1,0)+ -- libgit2 0.21.4