SMTP ET API CONFIGURATION

CritSend peut recevoir plus de 3 millions de courriels par heure. Nous pouvons augmenter ou diminuer cette capacité aussi rapidement que nécessaire car notre système est entièrement distribué et réparti partout dans le monde. Nous sommes en mesure d'envoyer vos courriels dans les deux minutes à condition que votre réputation auprès des FAI soit suffisante.

Plus d'informations de SMTP ->

A propos de SPF et DKIM

  • JAVA
  • PHP
  • RUBY
  • PYTHON
  • .NET
  •     
    /*
    * This class is just here for demo purposes.
    * File_name: example_script.java
    */
    package net.mxm.connector.test;

    import java.util.logging.Level;
    import java.util.logging.Logger;
    import net.mxm.connector.ArrayEmail;
    import net.mxm.connector.CampaignParameters;
    import net.mxm.connector.Content;
    import net.mxm.connector.Email;
    import net.mxm.connector.MxmConnect;
    import net.mxm.connector.MxmConnectConfigurationException;
    import net.mxm.connector.MxmConnectException;

    /**
    * @author nico toper
    * @date 2010-10-20
    */
    public class MxmTest extends Thread {
        public MxmConnect mxm = null;
        public int res[] = new int[20];
        public MxmTest() throws MxmConnectException {
        //mxm = new MxmConnect();
        for (int i = 0; i < res.length; i++) {
            res[i] = 0;
        }
    }

    @Override
    public void run() {
        for (int i = 0; i < 2000; i++) {
            try {
                try {
                    long fStart = System.currentTimeMillis();
                    this.sendEmail();
                    //System.out.println("Time for this mail: " + ( System.currentTimeMillis() - fStart) );
                    } catch (MxmConnectException ex) {
                        Logger.getLogger(MxmTest.class.getName()).log(Level.SEVERE, null, ex);
                    }
                } catch (MxmConnectConfigurationException ex) {
                    Logger.getLogger(MxmTest.class.getName()).log(Level.SEVERE, null, ex);
                }
        }
    }

    void testOthers() throws MxmConnectException, MxmConnectConfigurationException {
        MxmConnect mxm2 = new MxmConnect("", "");
        //  mxm2.createTag("test");
        // mxm2.createTag("test2");
        String[] t = mxm2.listAllTags();
        for (int i = 0; i < t.length; i++) {
            System.out.println(t[i]);
        }
        // System.out.println(mxm2.deleteTag("test2"));
    }

    private String makeRandom() {
        Double r = new Double(Math.random() * 1000000);
        return r.toString(r);
    }

    protected void sendEmail() throws MxmConnectConfigurationException, MxmConnectException {
        MxmConnect mxm2 = new MxmConnect("", "");
        //MxmConnect mxm2 = mxm ;
        // mxm2.setFastDelivery(true);
        CampaignParameters cp = new CampaignParameters();
        cp.setMailFrom("[email protected]");
        cp.setMailFromFriendly("FriendlyName");
        cp.setReplyTo(this.makeRandom());
        cp.setReplyToFiltered(false);
        String tags[] = { "test" };
        cp.setTags(tags);
        Content c = new Content();
        //c.setSubject(this.makeRandom());
        //c.setText(this.makeRandom());
        c.setSubject("Your Subject");
        c.setText("test");
        StringBuffer sb = new StringBuffer();
        String r = this.makeRandom();
        for (int i = 0; i < 2000; i++) {
            sb.append(r);
        }

        c.setHtml(sb.toString());
        Email e = new Email();
        e.setEmail("[email protected]");
        ArrayEmail ae = new ArrayEmail();
        ae.addEmail(e);
        String host = mxm2.getHost();
        System.out.println(host);
        System.out.println(mxm2.sendCampaign(c, cp, ae));
        //System.gc();
    }

    //This is the entry point for test.
    public static void main(String[] args) throws MxmConnectException, MxmConnectConfigurationException {
        //HeapMonitor h = new HeapMonitor();
        //h.start();
        for (int i = 0; i < 1; i++) {
            MxmTest mxm = new MxmTest();
            for (int j = 0; j < 100000; j++) {
                mxm.sendEmail();
                System.out.println("ok");
                for (int x = 0; x < mxm.res.length; x++) {
                    System.out.println(x + ": " + mxm.res[x]);
                }
            }
        }
    }

    Here’s another example, that teach you how to use our SMTP services:

    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    import javax.mail.*;
    import javax.mail.internet.*;
    import com.sun.mail.smtp.*;

    public class Distribution {
        public static void main(String args[]) throws Exception {
            Properties props = System.getProperties();
            props.put("mail.smtps.host","smtp.critsend.com");
            props.put("mail.smtps.auth","true");
            Session session = Session.getInstance(props, null);
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress("[email protected]"));
            msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse("[email protected]", false));
            msg.setSubject("Your subject here "+System.currentTimeMillis());
            msg.setText("Your content here");
            msg.setHeader("X-Mailer", "Header");
            msg.setSentDate(new Date());
            SMTPTransport t = (SMTPTransport)session.getTransport("smtps");
            t.connect("smtp.critsend.com", "YourCritSendUsername", "YourCritSendPassword");
            t.sendMessage(msg, msg.getAllRecipients());
            System.out.println("Response: " + t.getLastServerResponse());
            t.close();
        }
    }
  • /*
    * File_name: example_script.php
    */
    $content = array('subject'=> 'Subject', 'html'=> 'Html' , 'text' =>'Test');
    $param = array( 'tag'=>array('invoice1'), 'mailfrom'=> '[email protected]', 'mailfrom_friendly'=> 'Nicolas Toper', 'replyto'=>'[email protected]', 'replyto_filtered'=> 'true') ;
    $emails[0] = array('email'=>'[email protected]', 'field1'=> 'test');

    try {
        echo $j;
        print_r($mxm->sendCampaign($content, $param, $emails));
    } catch (MxmException $e) {
        echo $e->getMessage();
    }
  • ## File_name: example_script.rb
    #Put in a file like config/initializers/critsend.rb

    ActionMailer::Base.smtp_settings = {
        :address => "smtp.critsend.com",
        :port => 587,
        :authentication => :plain,
        :user_name => "YOUR_CRITSEND_USERNAME",
        :password => "YOUR_CRITSEND_PASSWORD",
        :enable_starttls_auto => false
    }

    ActionMailer::Base.delivery_method = :smtp
  • ## File_name: example_script.py
    import smtplib

    #your critsend's credentials
    critsend_user = 'YOUR CRITSEND USERNAME'
    critsend_password = 'YOUR CRITSEND PASSWORD'

    sender = "YOUR NAME "
    recipients = ['RECIPIENT EMAIL']
    subject = "My subject"content = """My email message"""

    message = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n%s" % (sender, ", ".join(recipients), subject, content))

    try:
        server = smtplib.SMTP("smtp.critsend.com", 587)
        server.ehlo()
        server.starttls()
        server.ehlo
        server.login(critsend_user, critsend_password)
        server.sendmail(sender, recipients, message)
        print "Successfully sent email"
    except SMTPException:
        print "Error: unable to send email"
  • ## File_name: example_script.py
    Download the package from https://newmkt.critsend.com/static/CritSendConnector.Net.zip