Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 4653 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I want bounces to go to a different email address than the from address, so I added the line, "props.put("mail.smtp.from", "[email protected]");" to the SendEmailWithAuthentication script (with the necessary escape characters for quotation marks).

But when I view the headers of the mail message, it still has the "from" address in the Return-Path.

Any suggestions?


RegisterGroovy(



"SendEmailWithAuthentication( from ; to ; subject ; htmlBody ; attachmentPath ; smtpHost ; username ; password )" ;



"import javax.mail.*;¶

import javax.mail.internet.*;¶

¶

Properties props = new Properties();¶

props.setProperty("mail.smtp.host", smtpHost);¶

props.setProperty("mail.smtp.auth", "true");¶

props.setProperty("mail.smtps.auth", "true");¶

¶

// *****this is what I added*****¶

props.put("mail.smtp.from", "[email protected]");¶

¶

MimeMessage msg = new MimeMessage(Session.getInstance(props));¶

Multipart content = new MimeMultipart();¶

// first the message body¶

MimeBodyPart bodyPart = new MimeBodyPart();¶

bodyPart.setContent(htmlBody, "text/html");¶

content.addBodyPart(bodyPart);¶

// then the attachment¶

if (attachmentPath) {¶

MimeBodyPart attachmentPart = new MimeBodyPart();¶

attachmentPart.attachFile(attachmentPath);¶

content.addBodyPart(attachmentPart);¶

}¶

msg.setContent(content);¶

msg.setSubject(subject);¶

msg.setFrom(new InternetAddress(from));¶

msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));¶

¶

Transport transport = Session.getDefaultInstance(props).getTransport("smtp");¶

int port = -1; // use the default port¶

transport.connect(smtpHost, port, username, password);¶

transport.sendMessage(msg, msg.getAllRecipients());¶

transport.close();¶

return true"



)

Posted

Are you trying to have two different from addresses??

There is a difference between 'from' and 'replyTo'

Maybe this will help

Posted

No, "Return-Path" is the address where bounces go, and is distinct from "From" and "Replyto". As a mail user, you wouldn't see this header unless you look for it. Usually, your SMTP server sets it to equal the "From" address, but for a mailing list, you want bounces to go to a "special place" for processing. Mail clients cannot set Return-Path as a normal header to the mail message. So if you want a custom Return-Path, your mail client must include an instruction for the SMTP server to set it for you. That's the job of

props.put("mail.smtp.from", "[email protected]");




Anyway, I have good news! I tried adding the above statement to one of the simpler Send Email examples in ScriptMaster, and it worked! It must have conflicted with one of the other statements in the more complicated "SendEmailWithAuthentication" module. Since I am no longer using the authentication feature, I have no problem using the simpler script.



My new registration script looks like this (adapted from "Send Email (HTML-Formatted)"):





RegisterGroovy( 

"SendEmailWithHtmlAndReturnPath( from ; to ; subject ; htmlBody ; smtpHost ; returnPath )" ; 

"import javax.mail.*;¶

import javax.mail.internet.*;¶

¶

Properties props = new Properties();¶

props.setProperty("mail.smtp.host", smtpHost);¶

props.put("mail.smtp.from", returnPath);¶

¶

MimeMessage msg = new MimeMessage(Session.getInstance(props));¶

msg.setContent(htmlBody, "text/html");¶

msg.setSubject(subject);¶

msg.setFrom(new InternetAddress(from));¶

msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to));¶

Transport.send(msg);¶

return true;"

)

  • Like 1

This topic is 4653 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.