Already registered? Log in
This guide provides a simple script to send out E-Mail using your SMTP2GO Account.
Please change the following variables in this guide:
Sender Name: the sender’s name.
sender@example.com: the sender’s email address.
Recipient Name: the recipient’s name.
recipient@example.com: the recipient’s email address.
USERNAME: your SMTP username.
PASSWORD: your SMTP password.
Please make sure that you have included Mail.php and Smtp.php with accurate path in your application.
PHP:
<?php
require_once 'Zend/Mail.php';
require_once 'Zend/Mail/Transport/Smtp.php';
$config = array('auth' => 'login',
'port' => 2525,
// 8025, 587 and 25 can also be used. Use Port 465 for SSL.
'username' => 'USERNAME',
'password' => 'PASSWORD');
$transport = new Zend_Mail_Transport_Smtp('mail.smtp2go.com', $config);
$mail = new Zend_Mail();
$mail->setFrom('sender@example.com', 'Sender Name');
$mail->addTo('recipient@example.com', 'Recipient Name');
$mail->setSubject('Your Subject');
$mail->setBodyText('Your Text message.');
$mail->setBodyHtml('Your Html message.');
try {
$mail->send($transport);
echo "Message has been sent.";
} catch (Exception $ex) {
echo "Failed to send mail " . $ex->getMessage();
}
?>
Try SMTP2GO free for as long as you like:
Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.