php sendcloud 发送邮件

function send_mail($to,$subject,$html) 
{
    ///首先设置账户密码,发送地址,api地址
    $api_user='sendcloud.org账户'; 
    $api_key='密码';
    $from='[email protected]';  ///域的邮件地址
    $fromname='苏苏';
    $url = 'http://sendcloud.sohu.com/webapi/mail.send.json';
    //不同于登录SendCloud站点的帐号,您需要登录后台创建发信子帐号,使用子帐号和密码才可以进行邮件的发送。
    $param = array( 'api_user' => $api_user,
                    'api_key' => $api_key,
                    'from' => $from,
                    'fromname' => $fromname,
                    'to' => $to,
                    'subject' => $subject,
                    'html' => $html
                    );

    $options = array('http' => array('method'  => 'POST','content' => http_build_query($param)));
    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

    $result=json_decode($result);
    return $result->message; ///成功 return success
 }

你可能感兴趣的:(PHP,发送邮件,sendcloud)