Mailgun:发送图像(HTML)和文本从Parse只显示HTML

Mailgun : sending image(HTML) and text from Parse shows only html

本文关键字:HTML 文本 Parse 显示 图像 Mailgun      更新时间:2023-09-26

这是我使用的代码

  Parse.Cloud.define("blendedBookMailToUser", function(request, response) {
           var Mailgun = require('mailgun');
           Mailgun.initialize('SandBoxCode', 'Key');
  Mailgun.sendEmail({
  to: "someone@gmail.com",
  from: "me@me.com",
  subject: "Session Booked",
  text: "HIIIIIIIIIIII" ,
  html:'<html><body style="text-align:center;"><img border="0" src="' + request.params.qrUrlKey + '" width="200" height="200" ></body></html>',
}, {
  success: function(httpResponse) {
    console.log(httpResponse);
    response.success("Email sent!");
  },
  error: function(httpResponse) {
    console.error(httpResponse);
    response.error("Uh oh, something went wrong");
  }
});
                   });

我收到邮件,但只有html部分-所以我只能看到没有文本的图像。如果我删除html部分,我将收到文本。

如何组合它们?有没有更好的方法来包含图像?

使用ios和Parse云代码

Text表示电子邮件的文本版本,而as HTML表示电子邮件的HTML版本。

为了查看文本,将文本合并到您的html版本的电子邮件中。

的例子:

var textMessage = "some text message";
Mailgun.sendEmail({
  to: "someone@gmail.com",
  from: "me@me.com",
  subject: "Session Booked",
  text: textMessage ,
  html:'<html><body style="text-align:center;"><img border="0" src="' + request.params.qrUrlKey + '" width="200" height="200" >' + textMessage + '</body></html>',
}, {
  success: function(httpResponse) {
    console.log(httpResponse);
    response.success("Email sent!");
  },
  error: function(httpResponse) {
    console.error(httpResponse);
    response.error("Uh oh, something went wrong");
  }
});

这将把文本信息放在图片的下方。