【问题标题】:How to send a template email using sendwithus?如何使用 sendwithus 发送模板电子邮件?
【发布时间】:2015-05-30 12:40:23
【问题描述】:

有没有办法使用 sendwithus 服务发送电子邮件模板? 我搜索了很多,但没有找到。

文档很差。

任何代码示例?我正在使用 PHP

【问题讨论】:

    标签: php sendgrid mandrill sendwithus


    【解决方案1】:

    这是一个使用 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);
    

    希望对你有帮助

    问候,

    罗杰

    【讨论】:

      【解决方案2】:

      您可以在此处找到 SendWithUs 模板文档:https://www.sendwithus.com/docs/templating。它解释了 API 调用和用于替换模板的各个方面所需的格式,这些模板存储在 SendWithUs 中。

      但是,您使用的是 PHP,他们有 created a library 供您使用,这也有助于处理模板方面的问题。

      【讨论】:

      • 谢谢你的链接,我已经看过它们了。问题是我找不到一个独立的示例来开始编辑和构建它。这些东西应该尽可能友好......
      • 如果您发布您当前拥有的代码,那就更好了,您至少可以从示例及其 github 中获取。
      • @Xalloumokkelos Martyn 对此答案的想法完全正确。如果您仍然遇到问题,请不要犹豫,发布您的代码或联系 sendwithus 支持 - 他们很乐意为您提供帮助。
      【解决方案3】:

      您是否看过这个关于如何开始使用 SendGrid + Sendwithus 的 video

      【讨论】:

      • 谢谢你。问题是我找不到一个独立的例子来开始编辑和构建它。这些东西应该尽可能友好......
      猜你喜欢
      • 2012-05-17
      • 2018-07-11
      • 2020-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 2020-09-11
      相关资源
      最近更新 更多