StarDomain

Sending Email from Your Website

By the StarDomain teamPublished 3 min read
Knowledge base article
Contents (6 sections)

Container Hosting does not include mailboxes. Your website can still send email (contact forms, order confirmations, password resets) by signing in to an email provider over SMTP, the same way an email app on your phone does.

What works and what does not

  • Works: SMTP with a username and password on port 587 (STARTTLS) or 465 (SSL/TLS).
  • Blocked: port 25. A hacked script sending straight to other mail servers is what gets a server's IP address blacklisted, so port 25 stays closed on every container.
  • Does not deliver: PHP's mail() function, and any plugin or script that relies on it. The message is accepted, so it looks sent, but it never leaves your container. It waits for port 25 and is discarded after five days. Configure SMTP instead.

Choose a provider

Any provider that gives you an SMTP login works. Common choices:

ProviderSMTP serverPortUsername
Gmail / Google Workspacesmtp.gmail.com587your Google address, with an app password
Zoho Mail (India)smtp.zoho.in587 or 465your Zoho address

For newsletters or high volume, use a transactional email service. Mailbox providers limit how many messages an account may send per hour.

Your container opens up to 30 new connections a minute to each mail server, after a burst of 10. A normal site sends well under that. Connections over it are dropped, so that send fails and the application should retry a minute later.

WordPress

WordPress sends with mail() by default, so its emails will not arrive until you add an SMTP plugin, such as WP Mail SMTP or FluentSMTP. In the plugin, enter:

  • SMTP host and port from the table above
  • Encryption: TLS for 587, SSL for 465
  • Authentication: on, with the mailbox address and password
  • From address: the same mailbox address

Then use the plugin's Send a test email button.

Other PHP applications

Most frameworks have an SMTP setting (Laravel: MAIL_MAILER=smtp in .env). In plain PHP, use a library such as PHPMailer:

php
$mail = new PHPMailer\PHPMailer\PHPMailer(true);
$mail->isSMTP();
$mail->Host       = 'smtp.zoho.in';
$mail->Port       = 587;
$mail->SMTPSecure = PHPMailer\PHPMailer\PHPMailer::ENCRYPTION_STARTTLS;
$mail->SMTPAuth   = true;
$mail->Username   = '[email protected]';
$mail->Password   = 'the mailbox password';
$mail->setFrom('[email protected]', 'My Website');

Never put the password in a file visitors can download, such as a .txt or .json file in public_html. Keep it in your application's PHP config file.

Make sure it lands in the inbox

  • Send from the address you log in with. A different From address is the most common reason mail goes to spam or is refused.
  • Your domain needs the SPF and DKIM records your provider gives you. Your provider lists the exact records to add.

It still does not arrive

  • Connection timed out: the application is using port 25. Change it to 587 or 465.
  • Authentication failed: check the username is the full address. Gmail needs an app password, not your normal one.
  • Sent, but not received: look in the recipient's spam folder, then check the SPF and DKIM records above.

Was this article helpful?

Your answer helps us decide what to improve next.

Still need help? Open a support ticket and our team will reply.

Prefer an app? Add this site to your home screen.Get the app
Sending Email from Your Website — Container Hosting