{"record":{"id":"ab21d0e478604825","repo":"apache/seatunnel","slug":"send-email-failed","errorCode":"SEND_EMAIL_FAILED","errorMessage":"Send email failed","messagePattern":"Send email failed","errorType":"error_code","errorClass":"EmailConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-email/src/main/java/org/apache/seatunnel/connectors/seatunnel/email/sink/EmailSinkWriter.java","lineNumber":167,"sourceCode":"\n            // Create multiple messages\n            Multipart multipart = new MimeMultipart();\n            // Set up the text message section\n            multipart.addBodyPart(messageBodyPart);\n            // accessory\n            messageBodyPart = new MimeBodyPart();\n            String filename = config.getEmailAttachmentName();\n            DataSource source = new FileDataSource(filename);\n            messageBodyPart.setDataHandler(new DataHandler(source));\n            messageBodyPart.setFileName(filename);\n            multipart.addBodyPart(messageBodyPart);\n            message.setContent(multipart);\n\n            //   send a message\n            Transport.send(message);\n            log.info(\"Sent message successfully....\");\n        } catch (Exception e) {\n            throw new EmailConnectorException(\n                    EmailConnectorErrorCode.SEND_EMAIL_FAILED, \"Send email failed\", e);\n        }\n    }\n\n    public void createFile() {\n        String fileName = config.getEmailAttachmentName();\n        try {\n            String data = stringBuffer.toString();\n            File file = new File(fileName);\n            // if file doesn't exist, then create it\n            if (!file.exists()) {\n                file.createNewFile();\n            }\n            FileWriter fileWriter = new FileWriter(file.getName());\n            fileWriter.write(data);\n            fileWriter.close();\n            log.info(\"Create File successfully....\");\n        } catch (IOException e) {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-email/src/main/java/org/apache/seatunnel/connectors/seatunnel/email/sink/EmailSinkWriter.java#L149-L185","documentation":"EmailSinkWriter.close() triggers sending of the composed MIME message via Transport.send(message). If the SMTP send fails for any reason (connectivity, authentication, protocol errors), the exception is wrapped in an EmailConnectorException with error code SEND_EMAIL_FAILED and the message \"Send email failed\".","triggerScenarios":"Closing an email sink after writing rows, when Transport.send fails: SMTP host unreachable, wrong port, TLS/SSL negotiation failure, authentication failure (wrong username/password), rejected recipients, or message content errors (bad attachments).","commonSituations":"Wrong smtp.host/port config; email provider requires OAuth/STARTTLS not configured; firewall or network egress blocked from the SeaTunnel worker; expired email account credentials; attachment file missing or unreadable.","solutions":["Verify SMTP configuration (host, port, auth, SSL/TLS settings) against your mail provider's documented settings.","Test SMTP connectivity from the SeaTunnel worker host: nc -vz <smtp.host> <port> or swaks --to test@example.com.","Check the wrapped cause ('Send email failed' has a cause chain) — look for AuthenticationFailedException (fix credentials) or unknown host (fix DNS).","Confirm the attachment path (email.attachment_name) exists on the worker and the account allows outbound mail/attachments.","Check firewall/egress rules so the worker can reach the SMTP server on the configured port (465/587/25)."],"exampleFix":"// before\nEmailSinkOptions.smtp_host = \"localhost\" // SMTP not running locally\n// after\nEmailSinkOptions.smtp_host = \"smtp.gmail.com\"\nEmailSinkOptions.smtp_port = 587\n// with correct username/app-password credentials","handlingStrategy":"try-catch","validationCode":"// Pre-flight SMTP connectivity and config check\nProperties props = new Properties();\nprops.put(\"mail.smtp.host\", smtpHost);\nprops.put(\"mail.smtp.port\", smtpPort);\nprops.put(\"mail.smtp.auth\", \"true\");\nTransport t = null;\ntry {\n    t = Session.getInstance(props).getTransport(\"smtp\");\n    t.connect(smtpHost, user, password); // fails fast if host/auth/port wrong\n} finally {\n    if (t != null && t.isConnected()) t.close();\n}","typeGuard":null,"tryCatchPattern":"try {\n    emailSinkWriter.close();\n} catch (EmailConnectorException e) {\n    if (EmailConnectorErrorCode.SEND_EMAIL_FAILED.equals(e.getSeaTunnelErrorCode())) {\n        Throwable cause = e.getCause();\n        log.error(\"SMTP send failed: \" + (cause != null ? cause.getMessage() : \"unknown\"), e);\n    }\n    throw e;\n}","preventionTips":["Validate smtp.host/port/auth settings against your mail provider docs before running jobs.","Test SMTP reachability from worker hosts (firewall/egress) before production runs.","Use app-specific passwords/OAuth where providers require them and rotate credentials.","Ensure attachment paths exist and are readable on all worker nodes."],"tags":["email","smtp","network","sink"],"backgroundTag":"http-request-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}