0

I have a Google apps script which sends an email with a long URL and a Bitly shortened one. However the GmailApp.sendEmail function silently fails if I include a Bitly URL. Simple example of problem code:

function myFunction() {

var sMail = "(my email address)";
var longURL = "https://www.google.com";
var shortURL = "(bitly URL)";


// Send email with information
  GmailApp.sendEmail( 
      sMail, 
      "URL Send Test",
      "Original URL: " + longURL + "\n" +
      "Short URL: " + shortURL
    );

}

This code executes without error, but I never receive the email or any notification that it was blocked. If I remove shortURL from the body then email is received.

Obviously these shortened links are a source of abuse (in fact I can't include it in my post) but is there a way around this? My script generates a long custom URL and shortening it is an important function.

Thanks for any suggestions.

user1355179
  • 89
  • 1
  • 8
  • Unfortunately, I cannot replicate your situation. When I send an email including your both URLs, no error occurs and the email can be sent. But, in your situation, is this thread useful? https://stackoverflow.com/a/72673568 In my answer, Firebase Dynamic Links API is used. If my answer was useful, I would like to flag it as a duplicated question. – Tanaike Feb 18 '23 at 01:04
  • As a matter of interest, what happens if the "Body" is written as `"Original URL: "+ longURL+"Short URL: "+shortURL` - that is, as a single line. – Tedinoz Feb 18 '23 at 03:59
  • I tested this in my personal Gmail account and it works fine, and now have narrowed this down to our email system. Turns out I can't get any message through which includes a bit.ly URL. Will proceed down that path. – user1355179 Feb 24 '23 at 07:25

0 Answers0