Send e-mail on behalf of the client

Asked

Viewed 1,015 times

4

I have a system that serves several clients and sends emails to their users (clients of my clients).

Today I use my own email account (from my domain), and in the composition of the email I inform the client’s name and email.

With that, I have two problems:

  1. These emails go into the spam box.
  2. The consignee may not reply to the email as it will not go to the specified sender, and yes my account.

What would be the best way to send these emails? I force the client to set up his own email account (at the risk of exceeding his daily send limit)?

Note: Send e-mail using javax.mail

3 answers

2

The ideal is to have a specific account for the system to send the emails, as seen around: [email protected], but actually the address doesn’t make much difference. The important thing is to hire a suitable plan that supports the expected volume of emails.

Usually the emails from companies are sent through the same hosting that they hire for the site, which ends up limiting the amount of emails to the basic plans. Consult the responsible company about current capacity and ask for plans to increase capacity.

Another alternative is to use another specific service for emails. Even with the domain of a site associated by the DNS to a specific hosting, it is possible to redirect the sending and receiving to different addresses, usually through the control panel or even asking for support of the hosting. This way, you are free to hire a reliable email service without changing the functioning of the company’s website.

  • The problem is that customers insist that the sender of the message has their domain, because it is the domain that their users know.

  • It’s okay to send emails with the users' domain. However, if the email service they use is bad, they will have to switch. The limits of sending hosting emails are usually specified in contract. Make an inquiry at the company responsible for the emails.

  • @Nilsonuehara I reworked the answer. See if it helps a little more.

  • Got it. so the solution is to authenticate/send the email via the client’s server.

  • @Nilsonuehara This depends on the service hired. For example, the Amazon service cited in the Emerson response would not use authentication on the client server. But if it is a "common" hosting then it would be the traditional SMTP authentication using the client credentials.

2

First of all, your server needs to be well configured or be considered as spammer until you are. This is because of Sender Policy Framework (SPF). This should be done at server level.

There are several locations that explain how to email from various languages, so I’ll focus on solving your main problem, not how to do it in the language.

Direct upload solution from your servers

Configure your server to work to meet the requirements of the Sender Policy Framework. This is not trivial, and you will be responsible for seeing complaints of SPAM, or even with it you may have IP banned.

This solution tends to give more trouble if the amount of sending emails is huge and at the same time.

Shipping solution via gateways Paid email guaranteeing delivery

If you can’t set up SPF, a viable option is to hire email gateway services such as Amazon Simple Email Service (Amazon SES), that release access data (for example, SMTP data that you could send from anywhere) and will do the service for you.

This solution tends to be simpler than setting up SPF, but is more expensive. It allows sending large amount of emails with less headache.

Simple and functional solution for few emails

Create a Gmail account, enable SMTP, and configure your framework to upload as if it were through that Gmail account. It works great and is the cheapest and easiest to ensure that your emails will reach 100% of the time, but requires you not to send MANY emails at the same time.

If you use the Google Apps for Business the email will be exactly that of the client’s domain, but the free quote nowadays does not allow many different accounts, but it is enough for small businesses.

  • If I understood correctly, in the "robust" form I would have to configure the mail server of each client so that they approve my server to send emails on their behalf. That’s it?

  • Well, in practice the server that will contact the rest of the world must have well-configured SPF. Your server doesn’t need to require SPF from your clients to receive email from them, but Google, Hotmail, and the like, require it. And even with SPF, bulk mailing will require an application that schedules and splits the workload, or even with SPF sending thousands of email in an hour will make emails enter the spam box if your IP is not previously trusted.

0

Note that we have some attributes in the message like From, where you can set the client’s email. Regarding server settings, I don’t know how to help at the moment.

// File Name SendHTMLEmail.java

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;

public class SendHTMLEmail
{
    public static void main(String [] args)
    {
        // Recipient's email ID needs to be mentioned.
        String to = "[email protected]";

        // Sender's email ID needs to be mentioned
        String from = "[email protected]";

        // Assuming you are sending email from localhost
        String host = "localhost";

        // Get system properties
        Properties properties = System.getProperties();

        // Setup mail server
        properties.setProperty("mail.smtp.host", host);

        // Get the default Session object.
        Session session = Session.getDefaultInstance(properties);

        try{
            // Create a default MimeMessage object.
            MimeMessage message = new MimeMessage(session);

            // Set From: header field of the header.
            message.setFrom(new InternetAddress(from));

            // Set To: header field of the header.
            message.addRecipient(Message.RecipientType.TO,
                new InternetAddress(to));

            // Set Subject: header field
            message.setSubject("This is the Subject Line!");

            // Send the actual HTML message, as big as you like
            message.setContent("<h1>This is actual message</h1>",
                "text/html" );

            // Send message
            Transport.send(message);
            System.out.println("Sent message successfully....");
        }catch (MessagingException mex) {
            mex.printStackTrace();
        }
    }
}
  • 1

    This is what I do currently, ie I authenticate myself in my mailserver and send with the customer sender. And that’s why messages end up falling into spam.

  • Hummm got it now

Browser other questions tagged

You are not signed in. Login or sign up in order to post.