A Java application for sending emails with attachments using JavaMail API.
EmailSender is a simple yet powerful Java utility that allows you to send emails with attachments programmatically. It leverages the JavaMail API to establish secure SMTP connections and send emails through Gmail's SMTP server.
- Send emails to specified recipients
- Include subject and HTML formatted message body
- Attach files to your emails
- Secure authentication using SSL
- Java JDK 8 or higher
- Maven for dependency management
-
Clone this repository:
git clone https://github.com/yourusername/email-sender.git -
Navigate to the project directory:
cd email-sender -
Build the project with Maven:
mvn clean package
-
Open
SendMailWithAttachment.javaand modify the following variables:to: The recipient's email addressfrom: Your Gmail addresspassword: Your Gmail password or app password- Attachment file path as needed
-
Run the application:
java -cp target/EnviarMail-0.0.1-SNAPSHOT.jar Sender
The project uses the following dependencies:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>It's recommended to use app-specific passwords instead of your main Google account password. You can generate one in your Google Account security settings.
Contributions are welcome! Feel free to submit a Pull Request.
Jon Ibarreche - jon.ibarreche@opendeusto.es
Copyright © 2021 Jon Ibarreche - All rights reserved