You need to sign in to do that
Don't have an account?
darh
debugging inbound email handling
As I just spent days debugging my inbound email application, I thought I'd share my hard-to-find mistakes in case they're not unique to me.
My implementation of Messaging.InboundEmailHandler worked just fine when I sent test emails from Outlook. Nothing happened when I sent emails via PHP's mail function. It appeared as if the email never even arrived.
My first mistake was not setting the Return-Path in PHP. Salesforce was generating email error messages, I just never got them.
The second error was an off-by-one count when parsing the email strings. I'm fairly sure that Outlook appends a \r\n (carriage return and a line feed), where the PHP code was only appending a \n. I never saw the System.StringException (which I wasn't testing for, either!) until I fixed the Return-Path problem.
Code & learn!
My implementation of Messaging.InboundEmailHandler worked just fine when I sent test emails from Outlook. Nothing happened when I sent emails via PHP's mail function. It appeared as if the email never even arrived.
My first mistake was not setting the Return-Path in PHP. Salesforce was generating email error messages, I just never got them.
The second error was an off-by-one count when parsing the email strings. I'm fairly sure that Outlook appends a \r\n (carriage return and a line feed), where the PHP code was only appending a \n. I never saw the System.StringException (which I wasn't testing for, either!) until I fixed the Return-Path problem.
Code & learn!
This is very helpful to see what is really going on when a live message is passed in (as opposed to a testmethod message).