Our Help Portal

Troubleshooting Support Articles
Searchable Help Information Repository
Self-Service Resources How-Tos
Technical Customer Walkthroughs   Browse All Knowledge ! ....

Get Prices Learn More

Breaking

< All Topics
Print

Send form mail using an SMTP relay server

To send form mail using an SMTP relay server, you’ll typically need to configure your email script or application to use the SMTP server’s settings. Below are general steps that you can follow:

1. Choose an SMTP Relay Service:

Select an SMTP relay service. Popular choices include SendGrid, SMTP.com, or your email provider’s SMTP service.

2. Obtain SMTP Relay Server Information:

  • SMTP Server Address: This is the address of the SMTP relay server. It’s provided by your chosen SMTP relay service.
  • SMTP Port: Common ports are 25, 587 (for TLS/STARTTLS), or 465 (for SSL).
  • Username and Password: You may need a username and password to authenticate with the SMTP relay server.

3. Update Your Form Mail Script or Application:

Adjust your form mail script or application to include the SMTP relay server settings. Below is a basic example in PHP using the PHPMailer library:

php
// Include PHPMailer library
require ‘path/to/PHPMailerAutoload.php’;

// Create a new PHPMailer instance
$mail = new PHPMailer;

// Set the SMTP settings
$mail->isSMTP();
$mail->Host = ‘your-smtp-server.com’;
$mail->SMTPAuth = true;
$mail->Username = ‘your-smtp-username’;
$mail->Password = ‘your-smtp-password’;
$mail->SMTPSecure = ‘tls’; // Use ‘tls’ or ‘ssl’
$mail->Port = 587; // Use the appropriate port

// Set other email settings
$mail->setFrom(‘your-email@example.com’, ‘Your Name’);
$mail->addAddress(‘recipient@example.com’, ‘Recipient Name’);
$mail->Subject = ‘Subject of the Email’;
$mail->Body = ‘Body of the Email’;

// Send the email
if (!$mail->send()) {
echo ‘Mailer Error: ‘ . $mail->ErrorInfo;
} else {
echo ‘Message sent!’;
}

4. Replace Placeholder Values:

Replace the placeholder values such as 'your-smtp-server.com', 'your-smtp-username', 'your-smtp-password', 'your-email@example.com', and 'recipient@example.com' with your actual SMTP relay server details and email addresses.

5. Install PHPMailer:

Make sure to download and include the PHPMailer library in your project. You can get it from the official GitHub repository or use Composer.

6. Test the Form:

After making the necessary changes, test your form to ensure that emails are being sent through the SMTP relay server.

Important Note:

  • Always handle sensitive information such as SMTP usernames and passwords securely. Avoid hardcoding them directly in your script.
  • Keep your script secure to prevent abuse by potential attackers.

This example uses PHPMailer, but the process is similar for other programming languages or frameworks. Adapt the code accordingly based on your specific requirements and programming environment.

Categories