const nodemailer = require('nodemailer');
(async () => {
const transport = nodemailer.createTransport({
service: 'Mailosaur',
auth: {
user: 'SERVER_ID@mailosaur.net',
pass: 'SMTP_PASSWORD'
}
});
await transport.sendMail({
subject: 'A test email',
from: 'Our Company <from@example.com>',
to: 'Test User <to@example.com>',
html: '<p>Hello world.</p>',
text: 'Hello world.'
});
})();
import smtplib
sender = "Our Company <from@example.com>"
recipient = "Test User <to@example.com>"
message = f"""\
Subject: A test email
To: {recipient}
From: {sender}
Hello world."""
with smtplib.SMTP("smtp.mailosaur.net", 2525) as server:
server.login("SERVER_ID@mailosaur.net", "SMTP_PASSWORD")
server.sendmail(sender, recipient, message)
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.mailosaur.net");
props.put("mail.smtp.port", "2525");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.ssl.protocols", "TLSv1.2");
props.put("mail.smtp.ssl.trust", "smtp.mailosaur.net");
Session session = Session.getInstance(props, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("SERVER_ID@mailosaur.net", "SMTP_PASSWORD");
}
});
MimeMessage message = new MimeMessage(session);
message.setSubject("A test email");
message.setFrom(new InternetAddress("Our Company <from@example.com>"));
message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress("Test User <to@example.com>"));
MimeBodyPart mimeBodyPart = new MimeBodyPart();
mimeBodyPart.setContent("<p>Hello world.</p>", "text/html; charset=utf-8");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mimeBodyPart);
message.setContent(multipart);
session.getTransport("smtp").send(message);
using MimeKit;
using MailKit.Security;
using MimeKit.Text;
var message = new MimeMessage();
message.From.Add(new MailboxAddress("Our Company", "from@example.com"));
message.To.Add(new MailboxAddress("Test User", "to@example.com"));
message.Subject = "A test email";
message.Body = new TextPart(TextFormat.Html) {
Text = "<p>Hello world.</p>"
};
using (var emailClient = new MailKit.Net.Smtp.SmtpClient()) {
emailClient.Connect("smtp.mailosaur.net", 2525, SecureSocketOptions.StartTls)
emailClient.Authenticate("SERVER_ID@mailosaur.net", "SMTP_PASSWORD");
emailClient.Send(message);
emailClient.Disconnect(true);
}
require 'net/smtp'
message = <<MESSAGE_END
From: Our Company <from@example.com>
To: Test User <to@example.com>
Subject: A test email
Hello world.
MESSAGE_END
Net::SMTP.start(
'smtp.mailosaur.net',
2525,
'smtp.mailosaur.net',
'SERVER_ID@mailosaur.net', 'SMTP_PASSWORD', :cram_md5
) do |smtp|
smtp.send_message message, 'from@example.com', 'to@example.com'
end
require_once('vendor/autoload.php');
$smtp = new Nette\Mail\SmtpMailer([
'host' => 'smtp.mailosaur.net',
'port' => 2525,
'username' => 'SERVER_ID@mailosaur.net',
'password' => 'SMTP_PASSWORD',
'secure' => 'starttls',
]);
$message = new Nette\Mail\Message;
$message->setFrom('Our Company <from@example.com>')
->addTo('Test User <to@example.com>')
->setSubject('A test email')
->setHtmlBody('<p>Hello world.</p>');
$smtp->send($message);
import (
"fmt"
"log"
"net/smtp"
)
func main() {
from := "from@example.com"
to := []string{
"to@example.com",
}
msg := []byte("From: Our Company <from@example.com>\r\n" +
"To: Test User <to@example.com>\r\n" +
"Subject: A test email\r\n\r\n" +
"Hello world.\r\n"
)
auth := smtp.CRAMMD5Auth("SERVER_ID@mailosaur.net", "SMTP_PASSWORD")
err := smtp.SendMail("smtp.mailosaur.net:2525", auth, from, to, msg)
if err != nil {
log.Fatal(err)
}
fmt.Println("Mail sent successfully!")
}