I am sending emails in my asp.net mvc application using postal. The emails are getting sent but the subject, from, cc and bcc fields are getting embedded in the email body instead of showing up in the appropriate areas.
Here are my smtp settings in web.config
<smtp from="[email protected]" deliveryMethod="Network">
<network host="mail.domain.com" userName="[email protected]" password="mypassword" defaultCredentials="false" port="25" />
</smtp>
Here is my email view
@{
Layout = null;
}
To: @ViewBag.To
From: [email protected]
Bcc: [email protected]
Subject: Welcome to @ViewBag.ClientName reporting system
Hello @ViewBag.Firstname,
Welcome.
Regards
My smtp settings in SmarterMail are correct and testing works perfectly. The problem is the formatting. How can I fix this?
The email gets sent but shows up like this:
From: [email protected]
To:
Date: Thu, 21 May 2015 16:40:34 +0300
Subject:
--email body starts here--
From: [email protected]
Bcc: [email protected]
Subject: Welcome to Client Name reporting system
Hello user,
Welcome.
Regards
UPDATE: Here is the code I'm using to send the email. I'm using postal
dynamic email = new Email("WelcomeEmail");
email.To = user.Email;
email.FirstName = user.FirstName;
email.ClientName = clientName;
email.Send();
Found the solution. The problem was Postal for some reason not picking up the email headers from my email view. So I set up all headers in the controller and only left the body of the email in the view. This is my updated email view.
and here is my updated setup in the controller