Streamlining file sharing: Why sending links beats attaching files in email

Tautvydas Tijūnaitis Tautvydas Tijūnaitis
· 9 min read · Tips and resources · February 29th, 2024
Traditionally, sending files as attachments, whether through the MailerSend API or SMTP, has been the go-to method for many of us. While it’s perhaps the most common way to send files, it has its limitations—especially when it comes to larger files.

But what if there's a more efficient way to share large files without these constraints? Imagine instead storing your file securely and simply sending a link via email. This approach not only bypasses size limitations but also opens up a realm of benefits, which we’ll explore in this article. So, let’s dive into why this method could be a game-changer for file sharing, plus some examples of how to get started.

The challenges of direct file sending via email

The primary challenge with email attachments is the ubiquitous size limit. While sending a PDF receipt or a small Excel file rarely poses an issue, larger files will undoubtedly hit a wall. 

The standard upper limit for attachment size is around 25MB, with some providers setting even stricter constraints. MailerSend caps file sizes at 25MB for API and SMTP transmissions—as does Gmail and Yahoo, while Outlook caps attachments at 20MB. 

Beyond size, security emerges as a significant concern. Direct file attachments face vulnerabilities in transit and upon delivery, especially if the email provider lacks robust security measures. There's also the issue of indefinite storage, which can become a security liability over time.

Moreover, email protocols, originally not designed for heavy file transfers, can lead to inefficiencies and delays. This is particularly problematic for transactional email delivery, where quick information transfer is often crucial. However, there's an efficient alternative to this method, which we'll explore in the following sections.

Storing files in the cloud and sharing them via links has become an increasingly popular alternative to traditional email attachments. This method offers numerous advantages, particularly when using established services like Amazon's S3, Google Cloud Storage, or Microsoft Azure Blob Storage.

Amazon S3, a frontrunner in this domain, exemplifies these benefits. It allows for the storage of files up to 5TB in size in the cloud, leveraging Amazon's extensive server network to ensure rapid upload speeds and global accessibility. 

The real game-changer, however, is the enhanced control it offers over file access. Users can choose to make files publicly accessible via a URL or keep them private, a flexibility that goes beyond the binary options of email attachments.

This approach translates to several clear advantages:

  • Increased storage and transfer capacity: Overcome the size limitations of email by storing and sharing larger files

  • Faster upload and access speeds: Utilize the speed and reliability of established cloud infrastructures

  • Customizable access control: Tailor file accessibility to specific needs, enhancing security and convenience.

However, it's important to acknowledge the costs associated with these services. While pricing models vary, they typically include charges for storage and data retrieval. For moderate usage, these costs are usually manageable and often outweighed by the benefits. And while we've highlighted Amazon S3 for its widespread use and longevity, alternatives like Google Cloud Storage and Microsoft Azure Blob Storage offer similar functionalities, mature technologies, and competitive pricing.

With these insights, it’s clear to see how implementing cloud storage and link sharing not only circumvents the limitations of traditional email attachments but also introduces a new paradigm in file management and sharing.

Comparing filesystem storage options

When it comes to choosing a file storage solution for internet transfers, the decision hinges on balancing various factors like control, scalability, cost, and specific business needs. Each option, from local storage to different cloud services, presents its unique set of strengths and limitations.

Local Storage

Local storage refers to storing files on in-house servers or company-owned hardware.

The primary advantage of this approach is the unparalleled level of control it offers over your data. Businesses with sensitive information or those required to comply with strict data protection regulations, such as government, banking, or healthcare organizations, may find this option more appealing. 

Additionally, local storage eliminates dependence on external service providers, ensuring direct access to data without internet connectivity. However, the challenges are significant. It requires substantial investment in infrastructure, ongoing maintenance, and robust security measures. Furthermore, scalability can be an issue, as increasing storage capacity often involves additional hardware and technical resources.

Amazon S3

Amazon S3, a leader in cloud storage solutions, offers a scalable, secure, and highly flexible environment for file storage. Its pay-as-you-go pricing model can be cost-effective for businesses with varying storage needs. 

S3's standout feature is its scalability, allowing companies to easily adjust their storage space as their needs evolve. Security in S3 is top-notch, with comprehensive encryption and access management options. The service also integrates with a wide array of other services and tools, making it a versatile choice for diverse applications. However, costs can escalate with increased usage, particularly for data transfer and retrieval, which is an important consideration for budgeting.

Google Cloud Storage

Google Cloud Storage is renowned for its deep integration with analytics and machine learning tools, making it an ideal choice for organizations that prioritize data-driven decision-making. 

Like Amazon S3, it offers scalable storage solutions with a similar pay-as-you-go pricing model. Google Cloud Storage stands out in its storage classes, designed to suit different frequencies of access, which can help optimize costs. Security and privacy features are robust, providing businesses with peace of mind. 

The platform’s deep integration with Google's ecosystem is a significant advantage for those already using Google services, although it may present a steeper learning curve for others.

Microsoft Azure Blob Storage

For enterprises that are heavily invested in the Microsoft ecosystem, Azure Blob Storage offers seamless integration with other Microsoft services. Its pricing is competitive, and for some businesses, particularly those in Windows-based environments, it can offer additional cost benefits. 

Azure Blob Storage is also known for its comprehensive security and compliance features, making it a secure choice for sensitive data storage. The service’s scalability is on par with its competitors, and its integration with Microsoft's suite of tools can greatly enhance productivity, especially for those already familiar with the Microsoft environment.

Now, let’s get down to business! For this example, we will look into how you can integrate Amazon S3 into your workflow of sending emails using the MailerSend API. We will be doing this in PHP, but the same flow will work on any language you choose to use.

Step 1: Set up your AWS account and S3 Bucket

1. Create an AWS account: If you don't have one, sign up for an AWS account at

2. Create an S3 Bucket: In the AWS Management Console, navigate to the S3 service and create a new bucket. Ensure that the bucket name is unique and choose the appropriate region.

Step 2: Create an IAM user and obtain access keys

1. Create an IAM User: Go to the IAM service in the AWS Management Console and create a new user with programmatic access.

2. Attach Policies: Assign the `AmazonS3FullAccess` policy to this user (or a more restrictive policy based on your requirements).

3. Get Access Keys: Once the user is created, note down the Access Key ID and Secret Access Key. You'll need these for your PHP application.

Step 3: Set Up AWS SDK for PHP

1. Install AWS SDK for PHP: Use Composer to install the AWS SDK for PHP. Run composer require aws/aws-sdk-php in your project directory.

2. Include the Autoloader: Use `require vendor/autoload.php'; in your PHP script to include the Composer autoloader.

Step 4: Upload a file to S3

1. Initialize the S3 client: Create a new instance of the S3 client with your access keys and chosen region.

use Aws\S3\S3Client;

   $s3 = new S3Client([
       'version' => 'latest',
       'region'  => 'your-region',
       'credentials' => [
           'key'    => 'your-access-key-id',
           'secret' => 'your-secret-access-key',

2. Upload a file:

  • Specify the bucket name, the key (file name in S3), and the source file path

  • Use the `putObject` method to upload

$result = $s3->putObject([
       'Bucket' => 'your-bucket-name',
       'Key'    => 'your-file-name',
       'SourceFile' => 'path/to/your/source/file',

Step 5: Generate a shareable link

1. Create a pre-signed URL:

  • If you want the file to be privately accessed and only shared via a link, use a pre-signed URL

  • Set an expiration time for the link

$cmd = $s3->getCommand('GetObject', [
       'Bucket' => 'your-bucket-name',
       'Key'    => 'your-file-name'

   $request = $s3->createPresignedRequest($cmd, '+20 minutes');
   $presignedUrl = (string) $request->getUri();

Now that your file is securely stored and you've generated a shareable URL, the next step is to send this link via email using the MailerSend API. 

Below, we'll walk you through a brief PHP example to demonstrate this process. Essentially, the task involves adding the generated link into the HTML body of your email. This method is not exclusive to PHP; it can be adapted to any programming language supported by MailerSend, offering flexibility depending on your development environment. Consult our developers' docs on how to send an email.

use MailerSend\MailerSend;
use MailerSend\Helpers\Builder\Recipient;
use MailerSend\Helpers\Builder\EmailParams;

$mailersend = new MailerSend(['api_key' => 'key']);

$recipients = [
    new Recipient('', 'Your Client'),

$emailParams = (new EmailParams())
    ->setFromName('Your Name')
    ->setHtml("Hello, <br> Please find the file at the following link: <a href='{$presignedUrl}'>Download File</a>")


With this, you should be able to send emails using S3 and MailerSend API. Make sure to test it and add proper error handling before using it in production applications.

Important Security and Operational Notes for AWS S3 and MailerSend API

Prioritize security by securely storing AWS credentials and MailerSend API keys, using environment variables or AWS IAM roles to prevent exposure in your code. 

Implement robust error handling in your PHP scripts to efficiently manage potential exceptions or errors during S3 file uploads and email transmissions via MailerSend. Be mindful of file permissions in S3, configuring them to match your privacy needs, and ensuring secure sharing of links through MailerSend, especially for sensitive content. This careful approach safeguards data integrity, maintains communication privacy, and upholds the overall reliability and security of your application.

For other cloud storage options, please consult Upload objects from a filesystem and Make Data Public for doing this using Google Cloud storage or Upload a block blob with Python for Microsoft Azure.

The shift from traditional email attachments to the use of cloud storage solutions and link-sharing represents a significant advancement in digital data management. By utilizing services like Amazon S3, Google Cloud Storage, and Microsoft Azure Blob Storage, you can achieve greater efficiency, enhanced security, and an improved user experience. 

What’s more, link-sharing doesn’t only address the inherent limitations of email-based file sharing but also opens up new possibilities for managing and accessing data in a more agile and secure digital landscape.

Tautvydas Tijūnaitis
I'm Tautvydas, Lead Developer at MailerSend. When I'm not busy coding, I live and breathe European football—whether watching games in stadiums or building my fantasy team online!