{"id":4270,"date":"2026-01-02T14:39:44","date_gmt":"2026-01-02T06:39:44","guid":{"rendered":"https:\/\/blog.quantoyo.com\/?p=4270"},"modified":"2026-01-02T14:40:14","modified_gmt":"2026-01-02T06:40:14","slug":"mail-server-%e6%b2%92%e6%9c%89-ptr-dkim-spf%e7%9a%84%e8%a7%a3%e6%b3%95-2","status":"publish","type":"post","link":"https:\/\/blog.quantoyo.com\/?p=4270","title":{"rendered":"Mail Server \u6c92\u6709 PTR \/ DKIM \/ SPF\u7684\u89e3\u6cd5(Sendgrid\u3001Brevo)"},"content":{"rendered":"\n<p>\u5176\u5be6\u5f88\u7c21\u55ae&#8230;<br>\u4f7f\u7528\u5176\u4ed6\u5ee0\u5546\u7684\u670d\u52d9\u5373\u53ef<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>\u5ee0\u5546\u4e00\uff1asendgrid<\/p>\n\n\n\n<p><a href=\"https:\/\/sendgrid.com\">https:\/\/sendgrid.com<\/a><\/p>\n\n\n\n<p>sendgrid\u539f\u672c\u53ef\u4ee5\u6bcf\u5929\u514d\u8cbb\u5bc4\u9001100 \u5c01\u4fe1\uff0c\u4f462025 \u958b\u59cb\uff0c\u514d\u8cbb\u5e33\u865f\u670960\u5929\u8a66\u7528\u671f\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8a3b\u518a sendgrid<\/li>\n\n\n\n<li>\u9a57\u8b49domain (Settings \u2192 Sender Authentication \u2192 Domain Authentication)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1366\" height=\"518\" src=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2026\/01\/image.png\" alt=\"\" class=\"wp-image-4271\" srcset=\"https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2026\/01\/image.png 1366w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2026\/01\/image-300x114.png 300w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2026\/01\/image-150x57.png 150w, https:\/\/blog.quantoyo.com\/wp-content\/uploads\/2026\/01\/image-768x291.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c31\u53ef\u4ee5\u5728\u9801\u9762\u5167\u627e\u5230API_KEY\uff0c\u586b\u5165 php \u5f8c\u5373\u53ef\u5bc4\u4fe1<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>&lt;?php\nuse PHPMailer\\PHPMailer\\PHPMailer;\nuse PHPMailer\\PHPMailer\\Exception;\n\nrequire __DIR__ . '\/vendor\/autoload.php';\n\n$mail = new PHPMailer(true);\n\ntry {\n    \/\/ === SMTP \u8a2d\u5b9a ===\n    $mail->isSMTP();\n    $mail->Host       = 'smtp.sendgrid.net';\n    $mail->SMTPAuth   = true;\n    $mail->Username   = 'apikey'; \/\/ \u56fa\u5b9a\u503c\n    $mail->Password   = '\u4f60\u7684_SENDGRID_API_KEY';\n    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;\n    $mail->Port       = 587;\n\n    \/\/ === \u5bc4\u4ef6\u8005 ===\n    $mail->setFrom('system@quantoyo.com', 'Quantoyo System');\n\n    \/\/ === \u6536\u4ef6\u8005 ===\n    $mail->addAddress('test@gmail.com'); \/\/ \u6539\u6210\u4f60\u8981\u6e2c\u8a66\u7684\u4fe1\u7bb1\n\n    \/\/ === \u5167\u5bb9 ===\n    $mail->isHTML(true);\n    $mail->Subject = '\u3010\u6e2c\u8a66\u4fe1\u3011eSIM \u767c\u9001\u6210\u529f';\n    $mail->Body = '\n        &lt;h2>\u60a8\u7684 eSIM \u5df2\u958b\u901a&lt;\/h2>\n        &lt;p>\u611f\u8b1d\u60a8\u4f7f\u7528 Quantoyo \u670d\u52d9\u3002&lt;\/p>\n        &lt;p>\u6b64\u70ba\u7cfb\u7d71\u81ea\u52d5\u901a\u77e5\u4fe1\uff0c\u8acb\u52ff\u56de\u8986\u3002&lt;\/p>\n    ';\n\n    $mail->AltBody = '\u60a8\u7684 eSIM \u5df2\u958b\u901a';\n\n    $mail->send();\n    echo \"\u2705 \u5bc4\u4fe1\u6210\u529f\";\n\n} catch (Exception $e) {\n    echo \"\u274c \u5bc4\u4fe1\u5931\u6557\uff1a{$mail->ErrorInfo}\";\n}\n?><\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6c92\u6709\u5167\u5efaPHPMailer\uff0c\u53ef\u4ee5\u53bbgithub \u6293\uff0c\u518d\u8f09\u5165\u5373\u53ef<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/PHPMailer\/PHPMailer\">https:\/\/github.com\/PHPMailer\/PHPMailer<\/a><\/p>\n\n\n\n<p>\u7a0b\u5f0f\u78bc\u4e0a\u65b9\u6539\u6210<\/p>\n\n\n\n<pre class=\"wp-block-code has-black-color has-cyan-bluish-gray-background-color has-text-color has-background has-link-color has-small-font-size wp-elements-971eb674e0a6339bb348eff5a584749b\"><code>require 'PHPMailer\/src\/PHPMailer.php';\nrequire 'PHPMailer\/src\/SMTP.php';\nrequire 'PHPMailer\/src\/Exception.php';\n\nuse PHPMailer\\PHPMailer\\PHPMailer;<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>=======\u9019\u662f\u5206\u9694\u7dda=======<\/p>\n\n\n\n<p>\u56e0\u70baSendgrid \u6709\u65e5\u671f\u9650\u5236\uff0c60\u5929\u5f8c\u6703\u76f4\u63a5\u88ab\u53d6\u6d88\u5e33\u865f<br>\u5f8c\u4f86\u63db\u6210\u4e86Brevo<\/p>\n\n\n\n<p><a href=\"https:\/\/www.brevo.com\">https:\/\/www.brevo.com<\/a><\/p>\n\n\n\n<p>Brevo \u7684\u514d\u8cbb\u984d\u5ea6\u662f\u300c\u6bcf\u5929 300 \u5c01\u300d\uff01\uff01\uff01<\/p>\n\n\n\n<p>\u57fa\u672c\u4e0a\u6b65\u9a5f\u5dee\u4e0d\u591a\uff0c\u4f46\u662fBrevo \u8ddfgoDaddy \u6709\u9023\u7dda\uff0c\u53ef\u4ee5\u81ea\u52d5\u8a2d\u5b9a\uff0c\u9019\u975e\u5e38\u7684\u68d2<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9ede\u64ca\u53f3\u4e0a\u89d2\u540d\u7a31 -> <strong>\u300cSenders, Domains &amp; Dedicated IPs\u300d<\/strong>\u3002<\/li>\n\n\n\n<li>\u9078\u64c7 <strong>\u300cDomains\u300d<\/strong> -> \u9ede\u64ca <strong>\u300cAdd a domain\u300d<\/strong>\u3002<\/li>\n\n\n\n<li>\u8f38\u5165\u4f60\u7684\u7db2\u57df\uff08\u4f8b\u5982 <code>yourdomain.com<\/code>\uff09\u3002<\/li>\n\n\n\n<li>\u8207goDaddy\u9023\u52d5\u8a2d\u5b9a CNAME \u8207 TXT<\/li>\n\n\n\n<li>Verify &amp; Authenticate\u300d<\/li>\n<\/ul>\n\n\n\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\u7a0b\u5f0f\u78bcUsername \u6703\u9700\u8981\u586b\u5beb<\/p>\n\n\n\n<pre class=\"wp-block-code has-cyan-bluish-gray-background-color has-background has-small-font-size\"><code>\n    $mail->Username   = 'XXXXXXX@smtp-brevo.com'; \/\/\u9019\u908a\u6703\u662f\u4e00\u500b brevo\u986f\u793a\u5728\u756b\u9762\u4e0a\u7684 mail\n    $mail->Password   = '\u4f60\u7684_SENDGRID_API_KEY';<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u5be6\u5f88\u7c21\u55ae&#8230;\u4f7f\u7528\u5176\u4ed6\u5ee0\u5546\u7684\u670d\u52d9\u5373\u53ef<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"[]"},"categories":[3],"tags":[710,76,711,709],"class_list":["post-4270","post","type-post","status-publish","format-standard","hentry","category-technology","tag-brevo","tag-php","tag-phpmailer","tag-sendgrid"],"_links":{"self":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/4270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4270"}],"version-history":[{"count":2,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/4270\/revisions"}],"predecessor-version":[{"id":4273,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=\/wp\/v2\/posts\/4270\/revisions\/4273"}],"wp:attachment":[{"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.quantoyo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}