This guide provides a simple script to send out E-Mail using your SMTP2GO Account. You may refer the Laravel Mail documentation for more options.

Step 1

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.

Step 2

Make changes to the configuration file app/config/mail.php as below. For a secure TLS connection, you can also try using Port Number 25, 8025 or 587.

<?php
return array( 
 'driver' => 'smtp', 
 'host' => 'mail.smtp2go.com', 
 'port' => 2525, 
 'from' => array('address' => 'sender@example.com', 'name' => 'Sender Name'), 
 'encryption' => 'tls', 
 'username' => 'USERNAME', 
 'password' => 'PASSWORD', 
 'sendmail' => '/usr/sbin/sendmail -bs', 
 'pretend' => false, 
);
?>

Step 3

Here the example at Mail::send() method, is a view file located at app/views/ folder. A sample content of the app/views/example.php view file looks like below:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example Template</title>	
</head>
<body>
  <h1>
    Hi, <?php echo $firstname; ?>
  </h1> 
  <p>
    This is a test message.
  </p>
</body>
</html>

Step 4

Add the following code in your application to send the email:

<?php
$data = ['firstname' => 'Recipient Name'];
	Mail::send('example', $data, function($message)
{
    $message->to('recipient@example.com', 'Recipient Name')->subject('Your Subject');
});
?>

Ready to get started?

Try SMTP2GO free for as long as you like:

Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.

Log In