I am currently working on a C # application where I create my own mail server that listens for SMTP traffic, including attachment data, and then detects an MX record for the email address and passes it to the recipient.
All of this works great, except for one strange problem that I don't understand.
The problem only affects the launch of the C # program on Linux under Mono, everything is fine with Windows.
The problem is that I have a mail server program running on port 26 (port 25 is already in use). Then I have a C # test program on my Windows PC that sends the file. Then I get the attachment data, which successfully writes the attachment to a temporary file, recreates the attachment object, and sends the attachment with a message. When the email message is received, the email content no longer exists, and the attachment is called noname , and if I look at the attachment, it has a part of the email headers and the base 64-line that makes up the attachment.
However, if i, then change the program to port 25, everything will be done in exactly the same way, but this time, when the email arrives in my gmail account, the email is completely in tact with the message body and the attachment with the correct name and format. I do not understand why running my program on Linux under a different port will cause this problem. I checked the headers between workers and non-workers, and everything looks fine.
This is a problem with mono. I also tried setting the port to port 25 for the smtp client when I send it to an MX record but don't do otherwise. The following is a way to send the application.
FileStream fileStream = new FileStream(attachmentTempName, FileMode.Open, FileAccess.Read); Attachment attachment = new Attachment(fileStream, attachments[0].realFileName, MediaTypeNames.Application.Octet); message.Attachments.Add(attachment); message.From = new MailAddress(emailInfo["EmailFrom"]); message.To.Add(emailInfo["EmailTo"]); message.Subject = emailInfo["Subject"]; if (emailInfo["Headers"] != "") { message.Headers.Add(getHeaders(emailInfo["Headers"])); } message.Body = emailInfo["Body"]; message.Body = "This is a test hardcoded"; if (emailInfo["EmailFormat"] == ManageEmail.EmailFormat.HTML.ToString()) { message.IsBodyHtml = true; } else { message.IsBodyHtml = false; } SmtpClient smtp = new SmtpClient(mxRecords[0]); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.Port = 25; smtp.Send(message);
Thanks for any help you can provide.