Send mail multiple recipients

Here are a few ways to send an email to multiple recipients:

Method 1: Using the "To" field

You can separate multiple email addresses in the "To" field with a semicolon (;) or a comma (,). For example:

To: [email protected]; [email protected]; [email protected]

Method 2: Using the "Bcc" field

You can also use the "Bcc" (Blind Carbon Copy) field to send an email to multiple recipients without showing their email addresses to each other. Separate the email addresses with a semicolon (;) or a comma (,). For example:

Bcc: [email protected]; [email protected]; [email protected]

Method 3: Using a mailing list or distribution list

Many email providers and services offer mailing lists or distribution lists that allow you to send an email to multiple recipients with a single address. For example, you can create a mailing list in Gmail or Outlook and add multiple email addresses to it.

Method 4: Using a third-party email service

There are also third-party email services that allow you to send emails to multiple recipients, such as Mailchimp, Constant Contact, or Campaign Monitor. These services often offer features like email templates, tracking, and analytics.

Example code in programming languages

Here are some examples of how to send an email to multiple recipients in different programming languages:

Python

import smtplib

recipients = ["[email protected]", "[email protected]", "[email protected]"]
subject = "Test email"
body = "This is a test email."

server = smtplib.SMTP("smtp.example.com")
server.sendmail("[email protected]", recipients, subject, body)
server.quit()

Java

import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

String[] recipients = {"[email protected]", "[email protected]", "[email protected]"};
String subject = "Test email";
String body = "This is a test email.";

Properties props = new Properties();
props.put("mail.smtp.host", "smtp.example.com");
Session session = Session.getInstance(props);

MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.setSubject(subject);
message.setText(body);

InternetAddress[] address = new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
    address[i] = new InternetAddress(recipients[i]);
}
message.setRecipients(Message.RecipientType.TO, address);

Transport.send(message);

JavaScript

const nodemailer = require("nodemailer");

const recipients = ["[email protected]", "[email protected]", "[email protected]"];
const subject = "Test email";
const body = "This is a test email.";

let transporter = nodemailer.createTransport({
  host: "smtp.example.com",
  port: 587,
  secure: false, // or 'STARTTLS'
  auth: {
    user: "[email protected]",
    pass: "password"
  }
});

let mailOptions = {
  from: "[email protected]",
  to: recipients,
  subject: subject,
  text: body
};

transporter.sendMail(mailOptions, (error, info) => {
  if (error) {
    return console.log(error);
  }
  console.log("Email sent: " + info.response);
});

Note: These examples are just a starting point and may require additional configuration and error handling depending on your specific use case.