laravel 邮箱发送

首先我们去SendCloud注册
https://www.sendcloud.net/email/#/welcome
发送设置 -->api用户
点击生成Api_key
需要密码登录密码生成在这里插入图片描述

 public function youjian(){
        $url = 'http://api.sendcloud.net/apiv2/mail/send';
      $API_USER = 'shendababy_test_vgz7xJ';
      $API_KEY = 'XRInCPgA8WqxPnn6';

      //您需要登录SendCloud创建API_USER,使用API_USER和API_KEY才可以进行邮件的发送。
      $param = array(
          'apiUser' => $API_USER,
          'apiKey' => $API_KEY,
          'from' => 'service@sendcloud.`在这里插入代码片`im',
          'fromName' => 'SendCloud测试邮件',
          'to' => '[email protected]',
          'subject' => '来自SendCloud的第一封邮件!',
          'html' => '爸爸好想再爱你一次儿子,再叫一声好吗',
          'respEmailId' => 'true');

    $data = http_build_query($param);

    $options = array(
          'http' => array(
          'method'  => 'POST',
          'header'  => 'Content-Type: application/x-www-form-urlencoded',
          'content' => $data
    ));

    $context  = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

    return $result;
    }

控制器别忘写web

猜你喜欢

转载自blog.csdn.net/weixin_43746366/article/details/88293088