smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
585 stars 176 forks source link

MVC Mailer with Gmail, From address and name is "me" instead of what is populated from form submission #149

Open theericharms opened 9 years ago

theericharms commented 9 years ago

Hi, Using mvcmailer to send emails for a form submission, and we set the From to be the name and email that was gathered in the form. We use an email account (ie: ourmail@domain.com) which is used as the email account to send us the form data. The email is sent to that same account.

All was working on our Arvixe mail server, but my client switched to Gmail for Business, and now when it comes into our Gmail inbox, the message is from "me", and has our name and our email address that we use to send the form data. Ive been trying to sort this out with Google support but they dont seem to know how to fix it.

Has anyone witnessed this before? heres an example of how we set the From parameter.

public virtual MvcMailMessage ContactUs(Contact contact) { ViewData["contactForm"] = contact;

        Debug.WriteLine(contact);

        return Populate(x =>
        {
            x.Subject = "Contact Form";
            x.ViewName = "ContactUs";
            x.To.Add(new MailAddress(ConfigurationManager.AppSettings["Email"]));
            x.Bcc.Add(new MailAddress(ConfigurationManager.AppSettings["BCCEmail"]));
            x.From = (new MailAddress(contact.Email, displayName: contact.Email));
            x.IsBodyHtml = true;
        });
    }

Thanks!