Question:
First of all I have been using your library for a few years now and it has been great!!
I am using the Chilkat Email C++ library to send emails from my application to pagers. I have found that in order for the email to send I must have a valid from address. This is normally fine but I have a client that wants the from information they see on their pager to not appear. This information I send to the pagers is time critical for the emergency medical industry and they do not want to scroll down a few lines to get to the message. Other clients have been able to get their service provider to remove this information but the one clients service provider says it can not be done. So, here is my question. Is there a way to send the emails out of my software without setting the from information?
Answer:
Yes, you can send an email without the "From" header field. Instead of calling SendEmail, you’ll need to call mailman.SendMime. The SendMime method has three arguments: a from address, a recipient list, and the complete MIME text of an email. You can get the MIME text of an email by calling GetMime on the email object. When you create your email, you would neglect to add a "From" header field so that the From header is missing from the email’s MIME. Instead, you pass the From address as the 1st argument of GetMime. (The 2nd argument of GetMime, which is the recipients list, should be a string containing a comma separated list of email addresses.)
A little background on how the SMTP protocol works: The SMTP client connects to the server, says hello, authenticates, etc. and then begins sending the email. It starts by issuing a "FROM" command to the SMTP server, followed by 1 or more "RCPT TO" commands (one for each recipient), and finally sends the MIME source of the email. By default, mailman.SendEmail uses the contents of the From header field as the value passed in the FROM command. The To, CC, and Bcc header fields are passed in the RCPT TO commands. (The Bcc header fields are missing from the email’s MIME header, making it a blind carbon-copy.) When you use SendMime, there is no need for the From, CC, or To header fields to match what is passed in the FROM and RCPT TO commands. In fact, they can be missing from the MIME header altogether.
One note: many mail servers will flag missing From, To, or CC headers as indicative of SPAM. The same goes if the header fields do not agree with the real recipients. You’ll have to experiment to see how your servers, or the receiving servers behave.