Mailgun là gì
Table of Contents
Send with SMTP or API¶
It’s up to you, whatever you find easier is fine with us. Here’s something to consider:
SMTP API
Flexible with existing apps
Faster (x3)
Open protocol
Assembly (don”t worry about MIME)
Scales better (Batch sending)
In short, SMTP is an open and established protocol with large ecosystem, while saigoncantho.com.vn API is better long term performance and maintenance wise.
Bạn đang xem: Mailgun là gì
curl -s –user ‘api:YOUR_API_KEY’ https://api.saigoncantho.com.vn.net/v3/YOUR_DOMAIN_NAME/messages -F from=’Excited User ‘ -F to=YOU
import java.io.File;import com.mashape.unirest.http.HttpResponse;import com.mashape.unirest.http.JsonNode;import com.mashape.unirest.http.Unirest;import com.mashape.unirest.http.exceptions.UnirestException;public class MGSample { // … public static JsonNode sendSimpleMessage() throws UnirestException { HttpResponseJsonNode> request = Unirest.post(“https://api.saigoncantho.com.vn.net/v3/” + YOUR_DOMAIN_NAME + “/messages”) .basicAuth(“api”, API_KEY) .field(“from”, “Excited User “) .field(“to”, “artemis
example.com”) .field(“subject”, “hello”) .field(“text”, “testing”) .asJson(); return request.getBody(); }}
# Include the Autoloader (see “Libraries” for install instructions)require ‘vendor/autoload.php’;use saigoncantho.com.vnsaigoncantho.com.vn;# Instantiate the client.$mgClient = saigoncantho.com.vn::create(‘PRIVATE_API_KEY’, ‘https://API_HOSTNAME’);$domain = “YOUR_DOMAIN_NAME”;$params = array( ‘from’ => ‘Excited User ‘, ‘to’ => ‘bob
example.com’, ‘subject’ => ‘Hello’, ‘text’ => ‘Testing some saigoncantho.com.vn awesomness!’);# Make the call to the client.$mgClient->messages()->send($tên miền, $params);
def send_simple_message(): return requests.post( “https://api.saigoncantho.com.vn.net/v3/YOUR_DOMAIN_NAME/messages”, auth=(“api”, “YOUR_API_KEY”), data={“from”: “Excited User “, “to”: using System;using System.IO;using RestSharp;using RestSharp.Authenticators;public class SendSimpleMessageChunk{ public static void Main (string args) { Console.WriteLine (SendSimpleMessage ().Content.ToString ()); } public static IRestResponse SendSimpleMessage () { RestClient client = new RestClient (); client.BaseUrl = new Uri (“https://api.saigoncantho.com.vn.net/v3”); client.Authenticator = new HttpBasicAuthenticator (“api”, “YOUR_API_KEY”); RestRequest request = new RestRequest (); request.AddParameter (“domain”, “YOUR_DOMAIN_NAME”, ParameterType.UrlSegment); request.Resource = “{domain}/messages”; request.AddParameter (“from”, “Excited User “); request.AddParameter (“to”, “bar
YOUR_DOMAIN_NAME”); request.AddParameter (“subject”, “Hello”); request.AddParameter (“text”, “Testing some saigoncantho.com.vn awesomness!”); request.Method = Method.POST; return client.Execute (request); }}
import ( “context” “github.com/saigoncantho.com.vn/saigoncantho.com.vn-go/v3” “time”)func SendSimpleMessage(tên miền, apiKey string) (string, error) { mg := saigoncantho.com.vn.Newsaigoncantho.com.vn(tên miền, apiKey) m := mg.NewMessage( “Excited User “, “Hello”, “Testing some saigoncantho.com.vn awesomeness!”, “YOU
YOUR_DOMAIN_NAME”, ) ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel() _, id, err := mg.Send(ctx, m) return id, err}
var API_KEY = ‘YOUR_API_KEY’;var DOMAIN = ‘YOUR_DOMAIN_NAME’;var saigoncantho.com.vn = require(‘saigoncantho.com.vn-js’)({apiKey: API_KEY, tên miền: DOMAIN});const data = { from: ‘Excited User ‘, to: ‘foo
example.com’, subject: ‘Hello’, text: ‘Testing some saigoncantho.com.vn awesomeness!’};saigoncantho.com.vn.messages().send(data, (error, body) => { console.log(body);});
NOTE: If you’re sending from our EU infrastructure, be sure to substitute our EU endpoint in the above example: https://api.eu.saigoncantho.com.vn.net/v3
What actually happened:
taobontreem.com assembled a MIME message.Added the log entries to our full text tìm kiếm index.Delivered the tin nhắn hộp thư online.
You can find your private API key on your dashboard.
# Swaks is an smtp of CURL, install it first:curl http://www.jetmore.org/john/code/swaks/files/swaks-20130209.0/swaks -o swaks# Set the permissions for the script so you can run itchmod +x swaks# It’s based on perl, so install perlsudo apt-get -y install perl# now send!./swaks –auth –server smtp.saigoncantho.com.vn.org –au postmaster
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 MGSendSimpleSMTP { public static void main(String args) throws Exception { Properties props = System.getProperties(); props.put(“mail.smtps.host”, “smtp.saigoncantho.com.vn.org”); props.put(“mail.smtps.auth”, “true”); Session session = Session.getInstance(props, null); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(“YOU
example.com”, false)); msg.setRecipients(Message.RecipientType.TO, addrs) msg.setSubject(“Hello”); msg.setText(“Testing some saigoncantho.com.vn awesomness”); msg.setSentDate(new Date()); SMTPTransport t = (SMTPTransport) session.getTransport(“smtps”); t.kết nối(“smtp.saigoncantho.com.vn.org”, “postmaster
YOUR_DOMAIN_NAME”, “YOUR_SMTP_PASSWORD”); t.sendMessage(msg, msg.getAllRecipients()); System.out.println(“Response: ” + t.getLastServerResponse()); t.close(); }}
// Using Awesome https://github.com/PHPMailer/PHPMailerphprequire ‘PHPMailerAutoload.php’;$mail = new PHPMailer;$mail->isSMTP(); // Set mailer to use SMTP$mail->Hosting = ‘smtp.saigoncantho.com.vn.org’; // Specify main and backup SMTP servers$mail->SMTPAuth = true; // Enable SMTP authentication$mail->Username = ‘postmaster
YOUR_DOMAIN_NAME’; // SMTP username$mail->Password = ‘secret’; // SMTP password$mail->SMTPSecure = ‘tls’; // Enable encryption, only ‘tls’ is accepted$mail->From = ‘YOU
example.com’); // Add a recipient$mail->WordWrap = 50; // Set word wrap to 50 characters$mail->Subject = ‘Hello’;$mail->Body = ‘Testing some saigoncantho.com.vn awesomness’;if(!$mail->send()) { echo ‘Message could not be sent.’; echo ‘Mailer Error: ‘ . $mail->ErrorInfo;} else { echo ‘Message has been sent’;}
import smtplibfrom tin nhắn hộp thư online.mime.text import MIMETextmsg = MIMEText(‘Testing some saigoncantho.com.vn awesomness’)msg = “Hello”msg = “foo
YOUR_DOMAIN_NAME’, ‘3kh9umujora5’)s.sendmail(msg, msg, msg.as_string())s.quit()
# install `mail` gem first: `gem install mail`require ‘mail’Mail.defaults do delivery_method :smtp, { :port => 587, :address => “smtp.saigoncantho.com.vn.org”, :user_name => “”, :password => “”, }endmail = Mail.deliver do to ‘bar
YOUR_DOMAIN_NAME’ subject ‘Hello’ text_part do body ‘Testing some saigoncantho.com.vn awesomness’ endend
using System;using System.IO;using MailKit;using MailKit.Net.Smtp;using MimeKit;using RestSharp;using RestSharp.Authenticators;public class SmtpMessageChunk{ public static void Main (string args) { SendMessageSmtp (); } public static void SendMessageSmtp () { // Compose a message MimeMessage mail = new MimeMessage (); mail.From.Add (new MailboxAddress (“Excited Admin”, “foo
“Testing some saigoncantho.com.vn awesomesauce!”, }; // Send it! using (var client = new SmtpClient ()) { // XXX – Should this be a little different? client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Kết nối (“smtp.saigoncantho.com.vn.org”, 587, false); client.AuthenticationMechanisms.Remove (“XOAUTH2”); client.Authenticate (“postmaster
import ( “github.com/jordan-wright/email”)func main() { e := tin nhắn hộp thư online.NewEmail() e.From = “Your Name ” e.To = string{“bar
example.com”} e.Subject = “Hello” e.Text = byte(“Testing some saigoncantho.com.vn awesomeness”) err := e.Send(“smtp.saigoncantho.com.vn.org:587”, smtp.PlainAuth(“”, “YOUR_USERNAME”, “YOUR_PASSWORD”, “smtp.saigoncantho.com.vn.org”)) if err != nil { panic(err) }}
Verify Your Tên miền¶
Add a tên miền you own and verify it by setting up the DNS records we provide (known as SPF and DKIM) at your DNS provider.
Why you need to verify your tên miền:
To prove that you are an authorized sender for the tên miền.Verified domains are not subject to a sending limit of 300 emails per day.No more “sent via taobontreem.com.org” message in your emails.Establishing a positive tin nhắn hộp thư online reputation for your own tên miền.taobontreem.com is less suspicious of traffic that is being sent on verified domains and so using one reduces the likelihood of being disabled.
How to verify your tên miền¶
Add your tên miền or subdomain.Open your DNS provider and add the two TXT DNS records provided.If you want taobontreem.com to track clicks and opens you can also add the CNAME record.MX records should also be added, unless you already have MX records for your tên miền pointed at another tin nhắn hộp thư online service provider (e.g. Gmail).
Xem thêm: Định Nghĩa Cash Ratio Là Gì, Chỉ Số Thanh Toán Tiền Mặt (Cash Ratio)
Once you’ve added the records and they’ve propagated, your tên miền will be verified.
If you will be creating a lot of domains, saigoncantho.com.vn offers an API endpoint for adding/editing/removing domains from your tài khoản. See the Domains endpoint for more information.
Add Sending & Tracking DNS Records¶
TypeValuePurpose
TXT
“v=spf1 include:taobontreem.com.org ~all”
SPF (Required)
TXT
Find this record in your Control Panel, Domains Tab
DKIM (Required)
CNAME
“taobontreem.com.org”
Tracking (Optional)
Note
While the CNAME is listed as optional, it is required to enable Unsubscribe and Click tracking links.
Add Receiving MX Records¶
Mail server for handling inbound messages. MX Information
TypeValuePurpose
MX
mxa.taobontreem.com.org
Receiving (Optional)
MX
mxb.taobontreem.com.org
Receiving (Optional)
Warning
Do not configure Receiving MX DNS records if you already have another provider handling inboundmail delivery (e.g. Gmail).
Common DNS Providers¶
Common providers are listed below. If yours is not listed, contact your DNS provider for assistance.
Xem thêm: Vốn Điều Lệ Tiếng Anh Là Gì? The Charter Capital Là Gì Charter Capital Là Gì
GoDaddy: MX – CNAME – TXT
NameCheap: All Records
Network Solutions: MX – CNAME – TXT
Rackspace Thư điện tử & Apps: All Records
Rackspace Cloud DNS: Developer Guide
Amazon Route 53: Developer Guide
DigitalOcean: saigoncantho.com.vn and DigitalOcean Guide
You are all set!
Read more about How to start receiving inbound tin nhắn hộp thư online and How to start tracking tin nhắn hộp thư online events.
Thể loại: Tin Tức