开发者

Why ftp credentials are stripped away from email body when using MailMessage in C#?

开发者 https://www.devze.com 2023-01-09 15:10 出处:网络
I am dispatching emails at clients, notifying them for specific content deliveries and I have a problem with the containing ftp uri in mail body. I am constructing the ftp uri alongside with ftp crede

I am dispatching emails at clients, notifying them for specific content deliveries and I have a problem with the containing ftp uri in mail body. I am constructing the ftp uri alongside with ftp credentials in the following format, but the credentials part is stripped away (the section user:pass@):

ftp://user:pass@server/relativepath/filename

The code is something like that:

mailTemplate += String.Format("<a href=\"{0}\">File FTP URI: {1}</a><br>",
  开发者_如何学Python  new Uri(ftpBaseLink, filename), filename);

and the email is dispatched with the following matter:

MailMessage message = new MailMessage(
    mailSettings.Smtp.From,
    mailTo,
    subject,
    mailMessage) { IsBodyHtml = true };
SmtpClient client = new SmtpClient();               
client.Send(message);

Is there any clue how can I override this "normalization"?


I think that there was a general "tightening" of security a while back because of the way URLs containing user:pass were being mis-used to fool people into thinking they were clicking on a link to http://www.mybank.com when the link itself was http://www.mybank.com:blah@www.adodgysite.com/fake_bank_site. Users are wiser now, but it may be that its this "lockdown" that is affecting you.

My suggestion would be to concatenate the URI yourself, without using Uri


off the top, i'd look into what 'new Uri(ftpBaseLink, filename)' becomes as a string.

0

精彩评论

暂无评论...
验证码 换一张
取 消