Jump to content

Send email HTML, unsubscribe header


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

Recommended Posts

Hi,

 

I have absolutely no knowledge in Java. I'm using all the function already in the demo file of ScriptMaster (Send Email With Attachments), I have a licence so I generated my plugin and run it on the server to send email.

 

It's not a mass mailing, I send individual email, it's a system that confirms appointment. The email is HTML formed for a better-looking experience.

 

I need to add:

#1-header info (maybe multiple items), otherwise I get flag (mostly by Hotmail) as spam, the header should at least include the "Unsubscribe-list:" attribute

#2-with the HTML email, I need a "text/plain" short version

 

I have a score of 9.1 right now on SpamAssassin but still get flag as spam (DKIM, DMARC, host name-mail server, IP is all good) on Hotmail. Not Gmail, and not my own Exchange server.

 

I currently use the default Java code in the demo file.

 

I need the code modification, please the whole code, not add this xblabla in the code as I have no clue the run down of Java. I've been searching all day how, I got some string of code, but when I add them to the original code, I either get an error or it doesn't do anything.

 

Thanks for your help.

 

JF

 

 

Link to comment
Share on other sites

Hello,

I apologize, but custom code falls out of the scope of our free support. However, we have developers who are able to provide consultation work for you. If you'd like to hire one of our developers to generate custom code, I can put you in touch with our Project Coordinator. Send us an e-mail at [email protected] or call us at 770-234-9293 making that request. You and the Project Coordinator will discuss the details of the work and determine an estimate for how much it will cost. We usually charge $185/hr for consultation work.

If you share your code, either we or someone else on the forum can point you in the right direction. Someone may even provide the code you need. Stackoverflow.com is a good resource, too. https://stackoverflow.com/questions/4365850/list-unsubscribe-in-e-mail-header-how-to

This may not be the solution, but I recently helped a customer with a similar issue---their e-mails were going to recipients' Spam folder---and we found that the issue was that they were trying to send an e-mail using a different domain from that of the email server. The e-mail server needed a SPF record that communicated to recipients' servers that it was authorized to send e-mails for that domain(http://bananatag.com/hub/spf-records-and-why-theyre-important/). That could be something to look into if you're using a different domain from your SMTP server.

If you're experiencing an issue with ScriptMaster itself, then that would be something we can help you with at no charge. Please produce the issue, then look for the log file capturing the behavior. You can reference our docs at the link below to help you locate the log file.

http://docs.360works.com/index.php/Plugin_log_files

Link to comment
Share on other sites

ScriptMaster is an army knife kind of plugin, giving you access to the whole of Java(Groovy) from inside FileMaker.

It will serve you well to start learning some Groovy at least - not simple but not difficult either - some research would have led you to here for example

https://help.returnpath.com/hc/en-us/articles/222445367-How-to-implement-the-List-Unsubscribe-header

For the paling part, I am sure there are questions and answers in this forum about that 

Link to comment
Share on other sites

6 hours ago, john renfrew said:

Thanks, I have seen that post long time ago, but I have no clue HOW to get it inside the Java and put it as a header in the code... that link only tells you that you need to have that header section, not how to get it into Java. And all the example that I found online don't work when I create a new module in the SM.

 

I'm always willing to learn more stuff and make my FM app better... but my main job is driving a HVAC business!! I'm pretty good with FM, 25 years of self learning, but I have my limits :)

 

My current code is (if I recall, I merge 2 module from the SM demo file to have a HTML option with inserting a file.

My Variables are

smtpHost. from, to, subject, htmlBody and attachmentPath

 

import javax.mail.*;
import javax.mail.internet.*;

Properties props = new Properties();
props.setProperty("mail.smtp.host", smtpHost);

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.send(msg);

return true

Then I would also want to have a variable to enter the "text/plain" version

 

Thanks

Link to comment
Share on other sites

Hello,

You would need to make use of the MimeMessage class's setHeader() function. You can set the e-mail as plain text with call

msg.setheader("Content-Type", "text/plain")

https://stackoverflow.com/questions/12511744/custom-mail-headers-using-mime-in-java

You may also need to specify "text/plain" as the second parameter in your [body object].setBody() call.

The proper key to set an Unsubscribe List is "List-Unsubscribe". At the link below, someone applies it, and also includes a loop the prints all the headers to the console. 

https://stackoverflow.com/questions/21959235/javamail-api-listing-header-doesnt-work

You can probably set a list of headers to a return variable to test out your function call, something like:

String headersList;
Enumeration headers = msg.getAllHeaders();
while (headers.hasMoreElements()) {
   Header header = (Header) headers.nextElement();
   headersList += "\n" + header.getName() + ": " + header.getValue());
}
return headersList;
Edited by sean360Works
accidentally tabbed out of message input and returned
  • Like 1
  • Haha 1
Link to comment
Share on other sites

Thanks, but it's all Chinese to me, I have no clue how to insert any of these info into one working script.

 

I can built an IKEA piece of furniture without the manual, but not java script !! I need to have the full script and copy it... of the "how to" otherwise I add lines of codes and only gets error.

 

Thanks

Link to comment
Share on other sites

This topic is 1715 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.