<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="Tahoma">In the system I'm building I am working with all my strings as binaries. I'm doing this because I'll be deploying on a 64 bit platform and don't need all the text I'm working with blowing up in size when there isn't any need for it. However I'm noticing an odd behavior when constructing emails to send over SMTP.</font><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; ">Basically what I'm doing is this:</div><div style="font-family: Tahoma; ">...</div><div style="font-family: Tahoma; ">Message_body = "This is a message body", <-- This part is actually more complex in that variables are being used along with string literals to form the entire body, which is why I initially create it as a string.</div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; ">Binary_message = erlang:term_to_binary(Message_body),</div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; ">email:send(Binary_message).</div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; ">The other module then does this:</div><div style="font-family: Tahoma; ">...</div><div style="font-family: Tahoma; ">Header = "From: xxx <xxx>\rTo: yyy<yyy>\rSubject: This is the subject\r",</div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; ">Full_message = Header ++ erlang:binary_to_list(Binary_message),</div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; ">send_email(Full_message).</div><div style="font-family: Tahoma; "><br></div><div style="font-family: Tahoma; "><br></div><div><font class="Apple-style-span" face="Tahoma">Now the message sends just fine and shows up in my email. However in front of the Message_body text are three extra characters "</font><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: monospace; line-height: 17px; ">ƒkŐ" </span><span class="Apple-style-span" style="color: rgb(42, 42, 42); line-height: 17px; "><font class="Apple-style-span" face="Tahoma">and if I change the second module to this:</font></span></div><div><font class="Apple-style-span" color="#2a2a2a" face="monospace"><span class="Apple-style-span" style="line-height: 17px;"><span class="Apple-style-span" style="font-family: Tahoma; color: rgb(0, 0, 0); line-height: normal; "><div style="text-indent: 0px !important; ">...</div><div style="text-indent: 0px !important; ">Header = "From: xxx <xxx>\rTo: yyy<yyy>\rSubject: This is the subject\r",</div><div style="text-indent: 0px !important; "><br style="text-indent: 0px !important; "></div><div style="text-indent: 0px !important; ">Body = erlang:binary_to_list(Binary_message),</div><div style="text-indent: 0px !important; "><br></div><div style="text-indent: 0px !important; ">Full_message = Header ++ Body,</div><div style="text-indent: 0px !important; "><br style="text-indent: 0px !important; "></div><div style="text-indent: 0px !important; ">send_email(Full_message).</div></span></span></font></div><div style="font-family: Tahoma; "><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: monospace; line-height: 17px; "><br></span></div><div style="font-family: Tahoma; "><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: monospace; line-height: 17px; "><br></span></div><div><font class="Apple-style-span" color="#2a2a2a" face="Tahoma"><span class="Apple-style-span" style="line-height: 17px;">Then the three characters change to these"</span></font><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: monospace; line-height: 17px; ">ƒk×</span><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: Tahoma; line-height: 17px; ">" and I simply can't figure out what is going on. Now I'm not building a mail server and I don't expect to be sending thousands of emails so working around this by simply treating all email text as strings (not converting to/from binary) is certainly not a problem. I am just curious if anyone can explain or help me figure out what is going on.</span></div><div><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: Tahoma; line-height: 17px; "><br></span></div><div><span class="Apple-style-span" style="color: rgb(42, 42, 42); font-family: Tahoma; line-height: 17px; ">Chris Hicks.</span></div><div><font class="Apple-style-span" color="#2a2a2a" face="monospace"><span class="Apple-style-span" style="line-height: 17px;"><br></span></font></div>                                        </body>
</html>