【发布时间】:2015-05-30 12:40:23
【问题描述】:
有没有办法使用 sendwithus 服务发送电子邮件模板? 我搜索了很多,但没有找到。
文档很差。
任何代码示例?我正在使用 PHP
【问题讨论】:
标签: php sendgrid mandrill sendwithus
有没有办法使用 sendwithus 服务发送电子邮件模板? 我搜索了很多,但没有找到。
文档很差。
任何代码示例?我正在使用 PHP
【问题讨论】:
标签: php sendgrid mandrill sendwithus
这是一个使用 sendwithus 发送电子邮件的简单类:
<?php
use sendwithus\API;
require_once 'vendor/autoload.php';
class Sendwithus {
const TEST_API_KEY = 'test_api_key_here';
//three examples in the web...just for testing...
const SENDWITHUS_BALLON_PARTY = 'tem_id_1';
const SENDWITHUS_HAPPY_EMAIL = 'tem_id_2';
const SENDWITHUS_ROBOT_WELCOME = 'tem_id_3';
private $api;
public function __construct(){
$options = array(
'DEBUG' => true
);
//login into Sendwithus with API key...
$this->api = new API(self::LIVE_API_KEY, $options);
}
public function send($template_id){
$this->api->send(
$template_id,
array('address' => 'foo@email.com')
);
}
}
//send email...
$sendwithus = new Sendwithus();
$sendwithus->send($sendwithus::SENDWITHUS_BALLON_PARTY);
希望对你有帮助
问候,
罗杰
【讨论】:
您可以在此处找到 SendWithUs 模板文档:https://www.sendwithus.com/docs/templating。它解释了 API 调用和用于替换模板的各个方面所需的格式,这些模板存储在 SendWithUs 中。
但是,您使用的是 PHP,他们有 created a library 供您使用,这也有助于处理模板方面的问题。
【讨论】:
您是否看过这个关于如何开始使用 SendGrid + Sendwithus 的 video?
【讨论】: