发送纯文本/文本电子邮件并在服务器的电子邮件响应中获取 =0D=0A
当我从我的网站向统一 http://co.za 注册商发送电子邮件并在邮件中抄送我自己时,我收到他们返回的一封电子邮件,内容是他们收到了电子邮件,但找不到一些信息,因为其中添加了那些有趣的字符。我看到该网站上有一篇以前的帖子,但似乎没有一个答案对我有用,我在谷歌上尝试了很多帖子和博客。
电子邮件的整个正文是由您从注册商网站获得的模板构成的,我使用等作为我需要填充和替换它们的详细信息,然后将电子邮件正文发送给注册商。
EX:
1a. Complete domain name: < domainname >
gets replaces with the domain name exmaple.co.za
我的代码:
MailMessage emailmsg = new MailMessage("[email protected]", "[email protected]");
emailmsg.Subject = "N domain domain.co.za";
emailmsg.Bcc.Add("[email protected]");
emailmsg.Body = Body;
emailmsg.IsBodyHtml = false;
var plainView = AlternateView.CreateAlternateViewFromString(Body, new ContentType("text/plain; charset=iso-8859-1"));
plainView.TransferEncoding = TransferEncoding.SevenBit;
emailmsg.AlternateViews.Add(plainView);
SmtpClient sSmtp = new SmtpClient();
sSmtp.Send(emailmsg);
此代码向我自己发送了一份密件抄送副本,从 Outlook 的外观来看,一切似乎都很好,我应该是这样,但是当他们收到它时,字符会被添加。它似乎是随机添加这些字符的。那么显然请求失败,因为找不到秒名称服务器。
返回的电子邮件:
Administrative Info
Contact: Administrator=0D=0A 4b. Title/posi= (Administrator)
Company: CompanyName Ltd
Postal: P.O Box 12841, Centrahill, 6006
Phone: +27.00000000=0D=0A 4f. Fax Number: +27.00000000=
Provided Nameserver information
Primary Server : ns1.nameserver.co.za
Secondary 1 : ns2.nameserver.co.za=0d=0a,
任何帮助将不胜感激。
注意:注册商要求电子邮件为纯文本格式,而不是 base64 或 html,因为他们的系统会获取纯文本/文本电子邮件和传真并自动处理它们。
谢谢
When i send a email from my site to Uniform http://co.za registrar and cc myself in the mail i get an email returned from them that they received the email, but cannot find some of the information as it has those funny characters added to it. I saw that there was a previous post on the site but none of the answers seem to work for me, and i tried alot of post and blog on google.
The entire body of the email is constructed of the template you get from the registrar site and i used etc as the detail i need to populate and replace those, then send the body of the email off to the registrar.
EX:
1a. Complete domain name: < domainname >
gets replaces with the domain name exmaple.co.za
My Code:
MailMessage emailmsg = new MailMessage("[email protected]", "[email protected]");
emailmsg.Subject = "N domain domain.co.za";
emailmsg.Bcc.Add("[email protected]");
emailmsg.Body = Body;
emailmsg.IsBodyHtml = false;
var plainView = AlternateView.CreateAlternateViewFromString(Body, new ContentType("text/plain; charset=iso-8859-1"));
plainView.TransferEncoding = TransferEncoding.SevenBit;
emailmsg.AlternateViews.Add(plainView);
SmtpClient sSmtp = new SmtpClient();
sSmtp.Send(emailmsg);
This code send a bcc copy to myself and from the looks of it through outlook all seems fine and i should be but when they receive it the characters gets added. it seems to randomly add those characters. then obviously the request fails as the seconds name server cannot be found.
Returned Email:
Administrative Info
Contact: Administrator=0D=0A 4b. Title/posi= (Administrator)
Company: CompanyName Ltd
Postal: P.O Box 12841, Centrahill, 6006
Phone: +27.00000000=0D=0A 4f. Fax Number: +27.00000000=
Provided Nameserver information
Primary Server : ns1.nameserver.co.za
Secondary 1 : ns2.nameserver.co.za=0d=0a,
Any help would be appreciated.
note: the registrar requires the the email be in plain text and not base64 or html whatsoever as their system picks up plain/text email and faxes and automatically processes them.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想通了,将我的代码更改为以下内容:
所有字符空间都像电子邮件模板中应有的那样保留。
希望这也会对某人有所帮助。
I figured it out, changed my code to the following:
All characters spaces are kept like they should be in the email template.
Hope this will help someone aswell.
=OD=OA 是 CrLf 的引用可打印表示形式。
如果你想使用 iso-8859-1 字符集,那么你需要去掉这一行:
如果你坚持使用 7 位编码,那么你只能在你的电子邮件中使用 ASCII 字符,所以改变 is0-8859 -1 字符集为“us-ascii”
=OD=OA is quoted-printable representation of CrLf.
If you want to use the iso-8859-1 characterset, then you will want to get rid of this line:
If you insist on using 7 bit encoding, then you can only use ASCII characters in your email, so change the is0-8859-1 characterset to "us-ascii"