Sample code for 30+ languages & platforms
Java

Set the X-Mailer Header of an Email

See more Email Object Examples

Demonstrates the Chilkat Email.Mailer property, which identifies the email software that sent the email. It corresponds to the MIME X-Mailer header. This example sets the mailer string and shows it in the generated MIME.

Background: X-Mailer is an optional, informational header — the X- prefix marks it as non-standard — that names the program used to compose or send the message. Mail servers do not require it and it has no effect on delivery; it is mainly useful for diagnostics and analytics. Because it is self-reported, it is trivially spoofable and should never be relied on for security decisions.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    //  Demonstrates the Email.Mailer property, which identifies the email software
    //  that sent the email.  This corresponds to the MIME X-Mailer header.

    CkEmail email = new CkEmail();

    email.put_Mailer("My Custom Mailer 1.0");

    System.out.println("Mailer = " + email.mailer());

    //  The X-Mailer header appears in the generated MIME.
    System.out.println(email.getMime());
  }
}