Knowledge Base
Home / Knowledge Base / Using UltraSMTP / Application Developers - Programming Applications to Send Mail Through UltraSMTP
Application developers can program their applications to send outgoing mail from their application through UltraSMTP using the following SMTP settings:
Outgoing SMTP Server Name | Port | Security |
---|---|---|
smtp.ultrasmtp.com | 465 | SSL/TLS |
smtp.ultrasmtp.com | 25 | STARTTLS |
smtp.ultrasmtp.com | 587 | STARTTLS |
Please see sample code below for Python, PHP and .NET.
Sample code in Python:
Sample code in PHP (using PHPMailer):
Sample code in .NET (Powershell)
Related:
Getting Started With UltraSMTP
Configuring Your Mail Client to Send Outgoing Mail Through UltraSMTP
Sample code in Python:
import smtplib recipientemail='recipient@recipientdomain.com' senderemail='sender@senderdomain.com' sendername='Joe Sender' subject='this is the subject line' body='this is the message body' smtpserver='smtp.ultrasmtp.com' smtpusername='yourultrasmtpusername' smtppassword='yourultrasmtppassword' message='' message+= "To: " + recipientemail + "\n" message+= "From: \"" + sendername + "\" <" + senderemail + ">\n" message+= "Subject: " + subject + "\n" message+= "\n" message+= body mailserver = smtplib.SMTP_SSL(smtpserver, 465) mailserver.ehlo() mailserver.login(smtpusername, smtppassword) mailserver.sendmail(senderemail, recipientemail, message) mailserver.quit()
Sample code in PHP (using PHPMailer):
require "class.phpmailer.php"; $mail = new PHPMailer; $mail->IsSMTP(); $mail->Host = "smtp.ultrasmtp.com"; $mail->Port = 465; $mail->SMTPAuth = true; $mail->Username = "yourultrasmtpusername"; $mail->Password = "yourultrasmtppassword"; $mail->SMTPSecure = 'ssl'; $mail->SetFrom("sender@senderdomain.com", "Joe Sender"); $mail->AddAddress("recipient@recipientdomain.com"); $mail->Subject = "this is the subject line"; $mail->Body = "this is the message body"; if(!$mail->Send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; exit; }
Sample code in .NET (Powershell)
$recipient = "recipient@recipientdomain.com" $sender = "sender@senderdomain.com" $subject = "this is the subject line" $body = "this is the message body" $smtpserver = "smtp.ultrasmtp.com" $smtpusername = "yourultrasmtpusername"; $smtppassword = "yourultrasmtppassword"; $SMTPMessage = New-Object System.Net.Mail.MailMessage($sender, $recipient, $subject, $body) $SMTPClient = New-Object Net.Mail.SmtpClient($smtpserver, 587) $SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential($smtpusername, $smtppassword); $SMTPClient.Send($SMTPMessage)
Related:
Getting Started With UltraSMTP
Configuring Your Mail Client to Send Outgoing Mail Through UltraSMTP