Visit https://myaccount.google.com/lesssecureapps and set on

require 'net/smtp'
sender = "your_email@gmail.com"
receiver = 'your_dest@gmail.com'
mail_pass = 'your_pass'
msg = %{From: Your Name <#{sender}>
To: Dest Name <#{receiver}>
MIME-Version: 1.0
Content-Type: text/html; charset=UTF8; format=flowed
Subject: E-mail subject goes here
<head>
  <body>
    <span style="color: red">Hello world</span>
  </body>
</head>}

smtp = Net::SMTP.new('smtp.gmail.com', 587)
smtp.enable_starttls

smtp.start('gmail.com', sender, mail_pass, :plain) do |smtp|
  smtp.send_message msg, sender, [receiver]
end
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
sender = 'your_email@gmail.com'
mail_pass = 'your_pass'
receiver = 'your_dest@gmail.com'

message = MIMEMultipart("alternative")
message['Subject'] = 'E-mail subject goes here boy!'
message['From'] = sender
message['To'] = receiver
html = """
<html>
  <head>
    <body>
      <span style="color: red">Hello world</span>
    </body>
</html>
"""
message.attach(MIMEText(html, "html"))
s = smtplib.SMTP('smtp.gmail.com', 587)
s.starttls()
s.login(sender, mail_pass)
s.sendmail(sender,receiver, message.as_string())
s.quit()
// in https://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eeplat-419426.html#javamail-1.4.7-oth-JPR
// download  javamail1_4_7.zip
// add mail.jar

package mail;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMail {
  public static void main(String[] args) throws AddressException, MessagingException {
    String receiver = "your_email@gmail.com";
    String sender = "your_dest@gmail.com";
    String username = sender;
    String password = "your_pass";
    String host = "smtp.gmail.com";
    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", "587");
    Session session = Session.getInstance(props, new javax.mail.Authenticator() {
      protected PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(username, password);
      }
    });
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(sender));
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiver));
    message.setSubject("Subject goes here");
    message.setContent(
      "<head>\n" + 
      "  <body>\n" + 
      "    <span style=\"color: red\">Hello world</span>\n" + 
      "  </body>\n" + 
      "</head>",
      "text/html");
    Transport.send(message);
    System.out.println("Done!");
  }
}

🗓 2017-10-16
630 👀