A Likely Fix for SMTP Send Mail Error 1506 Woes
(Updated January 11, 2011 10:20 am)
Send Mail via SMTP is a feature added in v10 of FileMaker Pro. The Send via SMTP option is also available to the Send Mail script step for FileMaker Pro, and is enabled for FileMaker Server. As a result we now have the ability to send email in the background (or in unattended mode via a server-side script), whereas prior versions required a FileMaker Pro client or third-party plug-in to send email.
As usual, with power comes responsibility. In this case, it means knowing your SMTP configuration details and correctly formatting email elements. Failure here is easy, often resulting in the general (and least informative) error, 1506: “Email(s) could not be sent successfully”. (See below for a common but unexpected condition that triggers this error.)
We’ve created a file that should help streamline the process of finding SMTP settings that work…(SMTP_SendMail_Interrogation.fp7; download now).
Update January 11, 2011 10:20 am: (added a config UI — script editing no longer required, as of v5!)
You provide the SMTP settings you want to examine for a particular SMTP mail server. When run, it will attempt to send email using every permutation of the settings, and tell you which combinations were successful. The test may take 60 seconds or longer to process all iterations.
Note: A puzzling cause of the 1506 error is related to the format of the email address given to the To: parameter, when you try to include the recipient’s name along with the address.
Specifically, it cannot be in the form that includes the full recipient name by using angle brackets around the email address: Full Name <email@example.com> =BAD. While the Send via E-mail Client option lets you include the recipient’s name with the email address, only the address should be used with the Send via SMTP option. The angle brackets will be rejected by most SMTP servers.
Recommended best practice: use the alternative form that places parentheses around the name, as so: firstname.lastname@example.org (Full Name) =GOOD. This will send both name and address when using the Send via E-mail Client option, and won’t trigger an error when using Send via SMTP.
Update November 10, 2009 10:30 am:
Let me add some clarity around FileMaker Pro’s Send Mail functionality, and the SMTP process in general. While the above fix will work as described, it doesn’t explain why. And it isn’t the whole story, because the FullName portion of an email such as “email@example.com (FullName)” is not used by the Send via SMTP option. So below I expand my description of the cause and note one potentially limiting effect.
First, the ‘Send via SMTP’ option of the Send Mail command (and script step) expects only an email address (e.g. firstname.lastname@example.org) as a value for the To: parameter. This is different than the To: field in an email client application (such as MS Outlook or Apple Mail), where a name can be entered along with the email address, usually in either of the two formats described above (with brackets or parentheses). The distinction is meaningful to this discussion because the two methods interact differently with SMTP mail servers.
When using the Send via SMTP option, any data in the To: other than the actual email address is superfluous to the SMTP server and usually is stripped out. Except for the angle brackets, which were required to delimit an email address in the original SMTP specification. This is why most mail client apps and middleware (PHP, Perl, etc.) functions will automatically add the brackets behind the scenes, if interpreted as missing. So another pair of brackets may be getting wrapped around your To: value, giving SMTP mail servers cause to reject the address and return an error.
Herein lies the caveat: we lose the ability to include a recipient’s name when we use FileMaker Pro’s Send via SMTP option. Now this really isn’t a major loss… people usually don’t display the To: column of their inbox. And since we’re not using an email client to send the message, we have no outbox in which to display a To: column.
One positive that I didn’t mention before: It may not be obvious that the To: parameter may contain multiple email addresses, separated by semi-colon or carriage returns.
Lastly, if the underlying mechanics are of interest, notice that the To: value in Send Mail’s dialog is evidently sent directly via a RCPT TO: command when Send via SMTP is the selected option. This RCPT TO: value is usually hidden in the message header, appearing as Envelope-To: — which must contain only a validly formatted email address. There also are RFC-compliance considerations at play, which constrain what can be done to the email header. Stray from the RFC specifications and your message will be considered malformed and rejected, or will be flagged as spam by most mail servers.
Hopefully, this single fix may resolve your troubles. Good luck!
File for download: SMTP_SendMail_Interrogation.fp7.zip