in reply to adding carriage return to gmail script

Based on Email::Send::SMTP::Gmail, I infer that the module is sending in text/html rather than text/plain (that's probably a gmail default or something), so newlines alone won't be sufficient. Replace your send line with:

$mail->send(-to=>"$to", -from=>"$from", -subject=>"$subject", -body=>j +oin "<br>\n", @push_list, "total files pushed: $filecount");

I took @push_list out of the string, because it doesn't stringify the way you think it does: it doesn't automatically add \n after each element of the list just because you say "@push_list\n". I converted that to a join to make sure every element is separated by the newline. I also changed the joining from just "\n" to "<br>\n", so that there will be an HTML break between each entry, not just a newline (which HTML ignores). Finally, I included the total-count string as part of the join, to automate a line break between your list and the total at the end.

TIMTOWTDI: instead of the the join, if you changed to local $" = "<br>\n";, then the stringification you used would do almost what you wanted... you'd just have to add a <br> before your final \n as well:

local $" = "<br>\n"; $mail->send(-to=>"$to", -from=>"$from", -subject=>"$subject", -body=>" +@push_list<br>\ntotal files pushed: $filecount");

edit: bumped the create button before finishing, so finished my example

edit2: here's a link to $LIST_SEPARATOR for $".

Replies are listed 'Best First'.
Re^2: adding carriage return to gmail script
by flieckster (Scribe) on Jun 13, 2016 at 16:20 UTC
    your first solution works adding the join, but adds the actual <br> into the email.
    1a.txt<br> 1b.txt<br> 1c.txt<br> 1d.txt<br> 1e.txt<br> 1f.txt<br> 1g.txt<br> 1h.txt<br> 1i.txt<br> 1j.txt<br> 1k.txt<br> 1l.txt<br> 1m.txt<br> 1n.txt<br> 1o.txt<br>
      Try adding content-type:
      $mail->send(-to .... -contenttype=>'text/html' );

              This is not an optical illusion, it just looks like one.

      Sorry. I've never used the module. When I didn't see the newline between the list of filenames and the "total files pushed", I assumed that HTML was swallowing the newline. When I skimmed the documentation, I saw the <BR> but didn't notice the -contenttype=>'text/html', so thought I had confirmation that it defaulted to HTML; oops.

      Now looking at the source of the OP, I now see that since the output was not wrapped in <c></c>, the post hid the newline that was actually there.

      To fix the example code, either use NetWallah's suggestion of -contenttype=>'text/html', or remove the unnecessary <br>'s from my example.

        that works perfect! thanks!