标签: sendgrid-api-v3

调用 /sendgrid-php/lib/helpers/mail/Mail.php 第 729 行中未定义的函数 SendGrid\mb_convert_encoding()

我该如何解决这个问题?

调用 /sendgrid-php/lib/helpers/mail/Mail.php 第 729 行中未定义的函数 SendGrid\mb_convert_encoding()

这是我的代码

<?php

require("./sendgrid-php/sendgrid-php.php");

$from = new SendGrid\Email(null, "example@example.com");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email(null, "example@example.com");
$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP");

// Send message as html
$mail = new SendGrid\Mail($from, $subject, $to, $content);

$apiKey = getenv('my key');
$sg = new \SendGrid($apiKey);

$response = $sg->client->mail()->send()->post($mail);

echo $response->statusCode();

print_r($response->headers());

echo $response->body();
Run Code Online (Sandbox Code Playgroud)

php email sendgrid-api-v3

2
推荐指数
1
解决办法
1792
查看次数

Custom_args 在 sendgrid V3 API 中不起作用,但 unique_args 发送电子邮件,但在 event_callback 中不起作用

我使用 sendgrid v3 api 发送电子邮件。正如 V3 API 文档中提到的,我使用 custom_args 来获取事件回调中的参数,但它显示 400 个错误请求,而我使用 unique_args 时,电子邮件已发送,但事件回调不会发送我的 unique_args 参数。

data = {"content": [{"value": "dfafds", "type": "text/plain"}], "attachments": [{"content": "UEsDBB......QACAgIAAA=", "type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "content_id": "BqzZqz7LaqO9", "filename": "Contactmanager-company.xlsx", "disposition": "attachment"}], "from": {"email": "bishnusyangja@gmail.com"}, "personalizations": [{"to": [{"email": "bishnu@janakitech.com"}], "custom_args": {"email_msg_id": 106}, "subject": "daff"}]}
Run Code Online (Sandbox Code Playgroud)

来自发送网格的事件回调响应是

[{"sg_event_id": "aoDNXRAeRuaCAVRiutD-fg",
"sg_message_id": "epJqlw1JThGw--dDTC1oCQ.filter0099p3las1-8681-5B853F95-29.0",
"smtp-id": "epJqlw1JThGw--dDTC1oCQ@ismtpd0006p1maa1.sendgrid.net",
"timestamp": 1535459222,
"email": "bishnu@janakitech.com",
"event": "processed"}]
Run Code Online (Sandbox Code Playgroud)

我需要在事件回调响应中自定义参数,在此响应中我需要email_msg_id这里缺少什么?

sendgrid sendgrid-api-v3

2
推荐指数
1
解决办法
5946
查看次数

553 5.1.3 收件人地址不是有效的 RFC-5321 地址

发送批量电子邮件时,我收到几条错误消息:

553 5.1.3 The recipient address <john@example.com > is not a valid RFC-5321 address.
Run Code Online (Sandbox Code Playgroud)

电子邮件地址的格式看起来完全有效,因此我一开始无法弄清楚为什么这些邮件没有被发送。

email sendgrid sendgrid-api-v3

2
推荐指数
1
解决办法
2万
查看次数

如何替换 Sendgrid 模板变量?(在 C# 中)

<%datetime%>在 SendGrid 模板中定义了一个变量。我根据这个命名约定决定遵循已经放置<%subject%>的主题行。我在示例中看到了不同的变量命名约定:https : //github.com/sendgrid/sendgrid-csharp/blob/master/SendGrid/Example/Example.cs#L41使用-name-and -city-,而https://github.com/sendgrid /sendgrid-csharp/blob/master/SendGrid/Example/Example.cs#L157使用%name%%city%

我只是假设变量替换基于简单的模式匹配,因此这些示例的对应模板包含完全相同的字符串。到目前为止,无论出于何种原因,这对我都不起作用。

string sendGridApiKey = ConfigurationManager.AppSettings["SendGridApiKey"].ToString();
var sendGrid = new SendGridAPIClient(sendGridApiKey);

string emailFrom = ConfigurationManager.AppSettings["EmailFrom"].ToString();
Email from = new Email(emailFrom);
string subject = "Supposed to be replaced. Can I get rid of this somehow then?";
string emaiTo = ConfigurationManager.AppSettings["EmailTo"].ToString();
Email to = new Email(emaiTo);
Content content = new Content("text/html", "Supposed to be replaced by the template. Can I get …
Run Code Online (Sandbox Code Playgroud)

c# sendgrid sendgrid-api-v3 sendgrid-templates

1
推荐指数
1
解决办法
3655
查看次数

SendGrid:向"多个收件人"发送电子邮件,而"收件人"字段中不显示其他电子邮件

我想向多个收件人发送电子邮件.

我使用个性化,但每个人的电子邮件都出现在"收件人"字段中,这违反了他们的隐私.

我不想使用BCC,因为这通常直接导致垃圾(例如http://www.standss.com/blog/index.php/why-you-should-avoid-using-bcc-for-emails/) .

因此,我的问题是,如何在没有每个人电子邮件出现在"收件人"字段的情况下向多个收件人发送电子邮件.

我能看到的唯一选择是使用循环向每个电子邮件发送一个单独的请求,当我有大量电子邮件要发送时,这个循环非常耗费资源并且非常耗时!

php sendgrid sendgrid-api-v3

1
推荐指数
1
解决办法
1812
查看次数

SendGrid:如何为发件人添加一个简单的非电子邮件地址名称

我正在为 Java 使用 SendGrid API v3。它可以工作并完成工作。但是,如果发件人hello@world.org,则收件人只会看到hello@world.org. 我试图完成的是,收件人也看到一个简单的名称(例如,Hello World <hello@world.org>),如下所示:

发件人地址和姓名示例

(上面注意,实际地址是noreply@k...,但前面是Kela Fpa。)

我怎样才能以编程方式做到这一点?

java sendgrid-api-v3

1
推荐指数
1
解决办法
976
查看次数

使用Node.js的SendGrid模板中的变量替换不起作用

在SendGrids上使用USE案例之后,github确实设法向我发送了带有正确模板的电子邮件,但是替换显然不起作用,并且在生成的电子邮件中留为空白。服务器端:

const sgmailer = require("@sendgrid/mail");
sgmailer.setApiKey(process.env.SENDGRID_API_KEY);
sgmailer.setSubstitutionWrappers('{{', '}}');

const msg = {
    to: '...',
    from: 'sender@example.org',
    subject: 'Hello world',
    text: 'Hello plain world!',
    html: '<p>Hello HTML world!</p>',
    templateId: '...',
    substitutions: {
        name: 'Some One',
        city: 'Denver',
    },
};
sgmailer.send(msg)
Run Code Online (Sandbox Code Playgroud)

模板中的HTML:

const sgmailer = require("@sendgrid/mail");
sgmailer.setApiKey(process.env.SENDGRID_API_KEY);
sgmailer.setSubstitutionWrappers('{{', '}}');

const msg = {
    to: '...',
    from: 'sender@example.org',
    subject: 'Hello world',
    text: 'Hello plain world!',
    html: '<p>Hello HTML world!</p>',
    templateId: '...',
    substitutions: {
        name: 'Some One',
        city: 'Denver',
    },
};
sgmailer.send(msg) …
Run Code Online (Sandbox Code Playgroud)

javascript node.js sendgrid-api-v3 sendgrid-templates

1
推荐指数
1
解决办法
823
查看次数

Sendgrid v3:“替代不能与动态模板一起使用”

我正在尝试将我的API代码从Sendgrid v2更新到实际的Sendgrid v3,所以我的代码以前看起来像这样:

public void sendCreatedUserEmail(User user) {
    Email from = new Email(FROM);
    from.setName(EMAIL_NAME);
    String subject = "Hello" + user.getName();
    Email to = new Email(user.getEmail());
    Content content = new Content("text/html", "Something");
    Mail mail = new Mail(from, subject, to, content);
    mail.personalization.get(0).addSubstitution("{name1}", user.getName());
    mail.personalization.get(0).addSubstitution("{name2}", user.getName());
    mail.setTemplateId(USER_TEMPLATE_ID);
    SendGrid sg = new SendGrid(SENDGRID_API_KEY);
    Request request = new Request();
    try {
        request.setMethod(Method.POST);
        request.setEndpoint("mail/send");
        request.setBody(mail.build());
        Response response = sg.api(request);
    } catch (IOException ex) {
        logger.error(ex);
    }
}
Run Code Online (Sandbox Code Playgroud)

经过几个小时的研究,我将v3更改为:(为了确保画面更清晰,我将所有内容分开)

public void sendCreatedUserEmail(User user) {
    Mail mail = …
Run Code Online (Sandbox Code Playgroud)

java maven sendgrid sendgrid-api-v3 sendgrid-templates

1
推荐指数
1
解决办法
1463
查看次数

Sendgrid 动态模板中的条件逻辑

我可以根据用户行为配置 Sendgrid 动态模板这些选项之一吗?

  • 要点击的一个或多个 URL
  • 重定向到表单

SendGrid 模板是否支持条件逻辑,或者是否有其他方法可以通过动态模板实现此目的?(实际上我正在寻找 AMP 替代品)

twilio sendgrid sendgrid-api-v3

1
推荐指数
1
解决办法
2017
查看次数