Neo Email can be configured on Email scripts using various coding languages. The major objective for doing this is to customize a contact form present on a website.
This article provides you with all the necessary configurations which you should know while configuring Neo on an email script.
The emails sent using this script will append those emails to the Sent folder of your Neo webmail.
List of settings that can be provided for configuring Neo on Email Scripts
SMTP Host Name |
smtp0001.neo.space |
Port No |
465 |
Encryption |
SSL |
Or
SMTP Host Name |
smtp0001.neo.space |
Port No |
587 |
Encryption |
STARTTLS |
Or
SMTP Host Name |
smtp0001.neo.space |
Port No |
25 |
Encryption |
None |
Code Snippets for reference
tabs |
|
PHP |
<?php // Include the PHPMailer library require 'vendor/autoload.php';
// Email configuration $sender_email = 'Your Neo email address'; $sender_password = 'Your Neo 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 = 'smtp0001.neo.space'; $smtp_port = 587;
// IMAP (receiving) server details $imap_server = 'imap0001.neo.space'; $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 Neo email address' sender_password = 'Your Neo 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 = 'smtp0001.neo.space' smtp_port = 587
# IMAP (receiving) server details imap_server = 'imap0001.neo.space' 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 Neo email address'; const senderPassword = 'Your Neo 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 = 'smtp0001.neo.space'; const smtpPort = 587;
// IMAP (receiving) server details const imapServer = 'imap0001.neo.space'; 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();
|
If the above settings are not working from an Email client or Script it should be happening because of the below-mentioned cases:
Case 1: Neo Mail cloud infra is blocking the client's IP
If there are continuously failed authentication attempts, we block the client's 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)/(25,None)
Get back to us with the output of the following commands
- "telnet smtp0001.neo.space <port-no>" (omit the quotes)
- "telnet Imap0001.neo.space <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 smtp0001.neo.space <port-no>" (omit the quotes)
- "telnet Imap0001.neo.space <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:
If you are using any other programming language, please let us know. So that we can provide you with the steps for that too :)
Hope this article has helped you.
Facing issues while configuring Neo on Email Scripts, contact us at hello@neo.space along with the screenshot of the configuration you are using and the error message you are receiving. We will help you in every possible way.