在找不到mailgun文档中我的问题的解决方案后,我将解释我在寻找什么.
今天我使用phpList发送我的新闻通讯(它工作得很完美!),我有HTML页面,我只是包含在phpList应用程序中发送出去.(我正在使用SMTP方法发送消息).我想知道我是否可以对mailgun做同样的事情(肯定可以,但是如何?),是否可以只包含我的HTML页面的路径来发送它?(我没有兴趣在脚本中输入我的html代码,它必须在路径中,否则我对使用mailgun没兴趣).
看看我的mailgun php代码如下:
$result = $mgClient->sendMessage("$domain",
array('from' => 'My Business Name <me@samples.mailgun.org>',
'to' => 'name-1@gmail.com, name-3@gmail.com, name-3@gmail.com',
'subject' => 'Issue Feb 2014',
'text' => 'Your mail do not support HTML',
'html' => '<html>Inline image: <img src="cid:Pad-Thai-1.jpg"></html>',
'recipient-variables' => '{"name-1@gmail.com": {"first":"Name-1", "id":1}, "name-2@gmail.com": {"first":"Name-2", "id": 2}}'),
array('inline' => 'Pad-Thai-1.jpg'));
Run Code Online (Sandbox Code Playgroud)
我有一个名为的数组元素'html'
,我想包含我的HTML页面的路径(如果不可能,我可以把它放在哪里?).我只是不能将我的整个HTML代码包含在这个html数组元素中,因为它是如此广泛.
但是,mailgun声称自己很容易,也很棒,这就是我想改变的动机.
isr*_*rar 37
我用这种方式使用了外部html模板.它可能对你有所帮助.
$html = file_get_contents('my_template.html'); // this will retrieve the html document
Run Code Online (Sandbox Code Playgroud)
然后:
$result = $mgClient->sendMessage("$domain",
array('from' => 'My Business Name <me@samples.mailgun.org>',
'to' => 'name-1@gmail.com, name-3@gmail.com, name-3@gmail.com',
'subject' => 'Issue Feb 2014',
'text' => 'Your mail do not support HTML',
'html' => $html,
'recipient-variables' => '{"name-1@gmail.com": {"first":"Name-1", "id":1}, "name-2@gmail.com": {"first":"Name-2", "id": 2}}'),
array('inline' => 'Pad-Thai-1.jpg'));
Run Code Online (Sandbox Code Playgroud)
检查这一行:
'html' => $html,
Run Code Online (Sandbox Code Playgroud)