views:

125

answers:

3

We have an app that allows users to send e-mails from our system. It allows the user to specify their e-mail address, and gives them several standard templates to use as a starting point for their e-mail.

When we send the e-mails, we use the address they provided as the 'reply-to', but the 'from' address of the e-mail (naturally) looks like our system (from '[email protected]').

Is there a way to change this without getting tangled up in spam filters or automatic blocking? We'd prefer not to confuse the recipient as to who actually composed the e-mail they've received.

+1  A: 

I'll refer you to Jeff Atwood's Coding Horror article about sending e-mail programattically. It describes in lengths the steps you should take to prevent your e-mail from being caught in spam filters, etc...

Jeff Atwood's Coding Horror: So You'd Like to Send Some Email (Through Code)

Aren
Thanks for the link (we already do all of that) but it doesn't answer the question I asked.
Jeff
Do you have a code sample? I interpreted the question as you wanted to know if changing the from would get your email tossed.
Aren
+1  A: 

I use this code:

public static bool sendEmail(string fromName, string fromEmail, string body, string subject, string toEmail) {

    String strReplyTo = fromEmail.Trim();
    String strTo = toEmail;
    String msgBodyTop = "Email from: " + @fromName + "(" + @fromEmail + ")\n"
            + "" + " " + DateTime.Now.ToLongTimeString()
            + " FROM " + HttpContext.Current.Request.Url.ToString + " : \n\n"
            + "---\n";

    MailMessage theMail = new MailMessage(fromEmail, strTo, subject, msgBodyTop + body);

    theMail.From = new MailAddress(strReplyTo, fromName);

    SmtpClient theClient = new SmtpClient(ConfigurationManager.AppSettings["SMTP"].ToString());

    theClient.Send(theMail);

    return true;
}

It seems to work for me...

Atømix
You don't have issues with triggering spam filters, spoofing the 'From' address like that?
Jeff
To be honest, I really haven't had a problem. However, I'm not doing mass mailouts either.
Atømix
A: 

After discussing with our ops people and trying Atomiton's method, I've found that this is not actually possible for us.

Jeff