1
$\begingroup$

I have run into a problem sending mail from within Mathematica. I can send attachments of most file types: .jpg, .nb, .xls, etc. I have run into a problem trying to send a zipped folder. I have looked for an explanation both here and on Gmail help, but have not been able to determine the cause of the problem. Any insight would be appreciated. Shown below are an example of an operation that works and an operation that fails.

The following works fine:

SendMail[
"To" -> "[email protected]",
"Subject" -> "Example of email sent from Mathematica",
"Body" -> 
"Hi.. I am testing something. There should be a picture attached.",
"Attachments" -> "picture.JPG",
"From" -> "[email protected]",
"Server" -> "smtp.gmail.com",
"UserName" -> "[email protected]",
"Password" -> Automatic,
"PortNumber" -> 587,
"EncryptionProtocol" -> "StartTLS"]

{"MessageID" -> "[email protected]"}

Whereas this fails:

SendMail[
"To" -> "[email protected]",
"Subject" -> "Example of email sent from Mathematica",
"Body" -> 
"Hi.. I am testing something. There should be a zipped folder attached.",
"Attachments" -> "stuff.zip",
"From" -> "[email protected]",
"Server" -> "smtp.gmail.com",
"UserName" -> "[email protected]",
"Password" -> Automatic,
"PortNumber" -> 587,
"EncryptionProtocol" -> "StartTLS"]

SendMail::timeout: A network operation for SendMail timed out. Please try again later. >>

$ Failed
$\endgroup$
4
  • 2
    $\begingroup$ What is in stuff.zip? gmail blocks zip files that contain zip files or executables. See Some file types are blocked. $\endgroup$
    – Mark Adler
    Commented Oct 14, 2014 at 3:14
  • 1
    $\begingroup$ I had seen this. The zip file only contains a couple of PDFs. $\endgroup$
    – navillus5
    Commented Oct 14, 2014 at 6:15
  • $\begingroup$ @navillus5 so you have tried e-mailing other domains and it also fails? $\endgroup$
    – rhermans
    Commented Oct 14, 2014 at 21:18
  • $\begingroup$ @rhermans I just performed a test - I send emails through both gmail and my university's server. I sent emails to a number of different addresses as well. All worked when I sent a single pdf, all failed whe sending a zipped folder containing three .xlsx files. ("SendMail::timeout: A network operation for SendMail timed out. Please try again later. >>) $\endgroup$
    – navillus5
    Commented Oct 15, 2014 at 11:46

1 Answer 1

1
$\begingroup$

I've experienced this Gmail limitation before... a workaround is to change the extension to something that is not blocked. Awesome security 'feature'.

For a compressed file like zip or 7z, simply change the file extension to .z and it should work. (.zipp might work too, but haven't personally used that)

To automate this...

The RenameFile documentation shows the basics of how to automate this:

Basically, use CopyFile to create a temp copy somewhere, rename this temp copy with RenameFile, as in "myCopiedFile.z", then use your SendMail routine. If the output from SendMail is not $Failed---in V10 you can use FailureQ for this check---you can use DeleteFile to clean up the temp (renamed) copy.

Side note...

If you are on Windows, file extensions known to Windows are usually hidden by default.

If you wanted to rename extensions 'by hand' you must change Windows 'Folder Options' -> 'View' tab -> uncheck 'Hide extensions for known file types'. I usually make this change for all folders, but I think you can just change the option for a specific folder and its subfolder(s), if you want.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.