Send e-mail on behalf of the customer

4

I have a system that serves multiple 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 name and email of the client.

With this, I have two problems:

  • These emails go to the spam box.
  • The recipient can not reply to the email because it will not go to the indicated sender, and yes my account.
  • What would be the best way to send these emails? Do I require the customer to set up an e-mail account of their own (running the risk of breaking their daily shipping limit)?

    Note: I send the email using javax.mail

        
    asked by anonymous 12.02.2014 / 12:57

    3 answers

    2

    The ideal is to have a specific account for the system to send the emails, as seen there: [email protected] , but in fact the address does not make so much difference. The important thing is to hire an appropriate plan that supports the expected volume of emails.

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

    Another alternative is to use another email-specific service. Even with the domain of a site associated with the DNS for a specific hosting, it is possible to redirect the sending and receiving to different addresses, usually through the control panel or even requesting the support of the hosting. That way you are free to sign up for a reliable email service without changing the way the company website works.

        
    12.02.2014 / 13:07
    2

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

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

    Direct shipping solution from your servers

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

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

    Shipping solution via paid gateways that guarantees delivery

    If you can not configure SPF, a viable option is to contract email gateway services, such as Amazon SES ( Amazon Simple Email Service ) , which releases 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 it is more expensive. Lets send large numbers of emails with less headache.

    Simple and functional solution for few emails

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

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

        
    12.02.2014 / 13:08
    0

    Note that we have some attributes in the message such as From, where you can set the client's email. Regarding the server settings, I do not 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();
            }
        }
    }
    
        
    12.02.2014 / 13:21