Titan Email can be configured on email scripts using various coding languages, such as PHP, Python, and Node.js. This is typically used to customize a contact form on a website so it sends mail through Titan. Once set up, emails sent through your script will also be copied to the Sent folder in your Titan webmail.
If you are based out of the European Union region then please refer to this article for Titan server details.
SMTP settings
Use one of the following two configurations:
SMTP Host Name
smtp.titan.email
Port No
465
Encryption
SSL
Or
SMTP Host Name
smtp.titan.email
Port No
587
Encryption
STARTTLS
Code snippets for reference
Sample scripts are provided below for PHP, Python, and Node Mailer. Replace the placeholder values (your Titan email address, password, and recipient email) with your own before running the script.
tabs
PHP
<?php
// Include the PHPMailer library
require 'vendor/autoload.php';
// Email configuration
$sender_email = 'Your Titan email address';
$sender_password = 'Your Titan password';
$recipient_email = 'Recipient email';
$subject = 'Testing email script';
$body = 'This is a test email sent from a PHP script.';
// SMTP (sending) server details
$smtp_server = 'smtp.titan.email';
$smtp_port = 587;
// IMAP (receiving) server details
$imap_server = 'imap.titan.email';
$imap_port = 993;
function send_email() {
global $sender_email, $sender_password, $recipient_email, $subject, $body, $smtp_server, $smtp_port, $imap_server, $imap_port;
// Create a PHPMailer object
$mail = new \PHPMailer\PHPMailer\PHPMailer();
try {
// Configure the SMTP settings
$mail->isSMTP();
$mail->Host = $smtp_server;
$mail->Port = $smtp_port;
$mail->SMTPAuth = true;
$mail->Username = $sender_email;
$mail->Password = $sender_password;
$mail->SMTPSecure = 'tls';
// Set the email content
$mail->setFrom($sender_email);
$mail->addAddress($recipient_email);
$mail->Subject = $subject;
$mail->Body = $body;
// Send the email
if ($mail->send()) {
echo 'Email sent successfully.';
} else {
echo 'Error sending email: ' . $mail->ErrorInfo;
return;
}
// Append the sent email to the IMAP server's "Sent" folder
// Enable the IMAP extension from your php.ini file
$imap_stream = imap_open("{" . $imap_server . ":" . $imap_port . "/ssl/novalidate-cert}", $sender_email, $sender_password);
if ($imap_stream) {
imap_append($imap_stream, "{" . $imap_server . ":" . $imap_port . "/ssl/novalidate-cert}Sent", $mail->getSentMIMEMessage());
echo 'Email appended to "Sent" folder.';
imap_close($imap_stream);
} else {
echo 'Error appending email to "Sent" folder.';
}
} catch (Exception $e) {
echo 'Error sending email: ' . $e->getMessage();
}
}
// Call the function to send the email and append it to the "Sent" folder
send_email();
?>
Python
import smtplib
import imaplib
import time
from email.mime.text import MIMEText
from email.header import Header
# Email configuration
sender_email = 'Your Titan email address'
sender_password = 'Your Titan password'
recipient_email = 'Recipient email'
subject = 'Testing email script'
body = 'This is a test email sent from a Python script.'
# SMTP (sending) server details
smtp_server = 'smtp.titan.email'
smtp_port = 587
# IMAP (receiving) server details
imap_server = 'imap.titan.email'
imap_port = 993
def send_email():
# Create the message
message = MIMEText(body, 'plain', 'utf-8')
message['From'] = sender_email
message['To'] = recipient_email
message['Subject'] = Header(subject, 'utf-8')
try:
# Send the email
smtp_obj = smtplib.SMTP(smtp_server, smtp_port)
smtp_obj.starttls()
smtp_obj.login(sender_email, sender_password)
smtp_obj.sendmail(sender_email, recipient_email, message.as_string())
smtp_obj.quit()
print('Email sent successfully.')
# Append the sent email to the IMAP server's "Sent" folder
imap_obj = imaplib.IMAP4_SSL(imap_server, imap_port)
imap_obj.login(sender_email, sender_password)
imap_obj.append('Sent', '', imaplib.Time2Internaldate(imaplib.Time2Internaldate(imaplib.Time2Internaldate(time.time()))), message.as_bytes())
imap_obj.logout()
print('Email appended to "Sent" folder.')
except smtplib.SMTPException as e:
print('Error sending email:', str(e))
except imaplib.IMAP4.error as e:
print('Error appending email to "Sent" folder:', str(e))
# Call the function to send the email and append it to the "Sent" folder
send_email()
Node Mailer
const nodemailer = require('nodemailer');
const Imap = require('imap');
const { simpleParser } = require('mailparser');
// Email configuration
const senderEmail = 'Your Titan email address';
const senderPassword = 'Your Titan password';
const recipientEmail = 'Recipient email';
const subject = 'Testing email script';
const body = 'This is a test email sent from a Node.js script.';
// SMTP (sending) server details
const smtpServer = 'smtp.titan.email';
const smtpPort = 587;
// IMAP (receiving) server details
const imapServer = 'imap.titan.email';
const imapPort = 993;
async function sendEmailAndAppend() {
try {
// Create a nodemailer transporter using SMTP
const transporter = nodemailer.createTransport({
host: smtpServer,
port: smtpPort,
auth: {
user: senderEmail,
pass: senderPassword,
},
});
// Create the email options
const mailOptions = {
from: senderEmail,
to: recipientEmail,
subject: subject,
text: body,
};
// Send the email
const info = await transporter.sendMail(mailOptions);
console.log('Email sent successfully.');
console.log('Info object:', info);
// Append the sent email to the "Sent" folder using IMAP
const imap = new Imap({
user: senderEmail,
password: senderPassword,
host: imapServer,
port: imapPort,
tls: true,
});
imap.once('ready', () => {
imap.openBox('Sent', true, (err) => {
if (err) {
console.error('Error opening "Sent" folder:', err);
imap.end();
return;
}
// Create the email message as MIMEText
const emailMessage = `From: ${senderEmail}\r\nTo: ${recipientEmail}\r\nSubject: ${subject}\r\n\r\n${body}`;
// Append the sent email to the "Sent" folder
imap.append(emailMessage, { mailbox: 'Sent' }, (appendErr) => {
if (appendErr) {
console.error('Error appending email to "Sent" folder:', appendErr);
} else {
console.log('Email appended to "Sent" folder.');
}
imap.end();
});
});
});
imap.once('error', (imapErr) => {
console.error('IMAP Error:', imapErr);
});
imap.connect();
} catch (error) {
console.error('Error sending email:', error);
}
}
// Call the function to send the email and append it to the "Sent" folder
sendEmailAndAppend();
Troubleshooting
If the settings above aren't working from an email client or script, it's usually one of the following two cases.
Case 1: Titan Mail cloud infra is blocking the client IP
If there are continuously failed authentication attempts, we block the client IP
If you are is trying to connect from your local machine, Kindly get back to us with the public IP by accessing https://www.whatismyip.com/
If you are trying to connect from the Webhosting, Kindly contact the system administrator and get back to us with the Server's public IP
Case 2: Client is blocking the port connection at their end ( Port is blocked at the firewall)
If you are is trying to connect from your local machine
Kindly use a different port combination: (465,SSL)/(587,STARTTLS)
Please get back to us with the output of the following commands
"telnet SMTP.titan.email <port-no>" (omit the quotes)
"telnet IMAP.titan.email <port-no>" (omit the quotes)
If you are trying to connect from the Webhosting
Contact the server admins to get back to us with the output of the following command
"telnet SMTP.titan.email <port-no>" (omit the quotes)
"telnet IMAP.titan.email <port-no>" (omit the quotes)
You must first enable telnet commands in order to run telnet commands. For information on how to enable telnet commands for your specific operating system, kindly refer to these articles: