{"id":17139841,"url":"https://github.com/lixuancn/mailservice","last_synced_at":"2025-03-24T07:50:28.355Z","repository":{"id":57604317,"uuid":"95505422","full_name":"lixuancn/mailservice","owner":"lixuancn","description":"发送邮件的服务","archived":false,"fork":false,"pushed_at":"2017-09-11T09:38:01.000Z","size":12472,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T13:22:17.794Z","etag":null,"topics":["golang","http","mail","sendmail"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lixuancn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-27T01:39:12.000Z","updated_at":"2018-10-06T02:22:48.000Z","dependencies_parsed_at":"2022-09-04T13:52:13.014Z","dependency_job_id":null,"html_url":"https://github.com/lixuancn/mailservice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixuancn%2Fmailservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixuancn%2Fmailservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixuancn%2Fmailservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lixuancn%2Fmailservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lixuancn","download_url":"https://codeload.github.com/lixuancn/mailservice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245232647,"owners_count":20581697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","http","mail","sendmail"],"created_at":"2024-10-14T20:13:14.012Z","updated_at":"2025-03-24T07:50:28.324Z","avatar_url":"https://github.com/lixuancn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 邮件发送服务\n\n### 功能\n能发邮件、抄送、HTML内容、附件等\n\n### 起因\n项目需要发送邮件给公司人员\n\n### 参考\n- github.com/open-falcon/mail-provider\n\n- github.com/scorredoira/email 这本来是个发邮件的包, 我想自己造个轮子, 就参考了它, 然后抛弃了它。\n\n### 依赖\n- Linux下的sendmail\n\n### 原理\n使用SMTP服务发送。\n\n### 用法\n\n- Protocol: HTTP\n\n- Method: POST\n\n- 发件箱中文名: 必填, fromname string \n\n- 发件箱地址: 必填, fromaddress string\n\n- 收件人: 必填, tos string, 多个用逗号分隔\n\n- 抄送人: 选填, ccs string, 多个用逗号分隔\n\n- 主题: 必填, subject string\n\n- 内容: 必填, content string, 可用HTML代码\n\n- 附件: 选填, attachment, 可单文件可数组\n\n- 编码: 选填, body_content_type string, 默认是text/plain, 可选是text/html等\n\n### 实例\n##### FORM表单\n```html\n\u003cform method=\"post\" action=\"http://****:4000/mail\" enctype=\"multipart/form-data\"\u003e\n    \u003cinput type=\"text\" name=\"fromname\" value=\"**邮件系统\"\u003e\u003cbr\u003e\n    \u003cinput type=\"text\" name=\"fromaddress\" value=\"example@example.com\"\u003e\u003cbr\u003e\n    \u003cinput type=\"text\" name=\"tos\" value=\"***@qq.com,***@qq.com\"\u003e\u003cbr\u003e\n    \u003cinput type=\"text\" name=\"ccs\" value=\"***@163.com,***@163.com\"\u003e\u003cbr\u003e\n    \u003cinput type=\"text\" name=\"subject\" value=\"搭建邮件服务器-测试附件发送\"\u003e\u003cbr\u003e\n    \u003cinput type=\"text\" name=\"body_content_type\" value=\"text/html\"\u003e\u003cbr\u003e\n    \u003cinput type=\"file\" name=\"attachment\"\u003e\u003cbr\u003e\n    \u003cinput type=\"file\" name=\"attachment\"\u003e\u003cbr\u003e\n    \u003ctextarea name=\"content\"\u003e\n\u003cp\u003e测试邮件发送服务\u003c/p\u003e\n\u003cp\u003e附件、抄送等功能\u003c/p\u003e\n\u003cimg src=\"http://*****.png\"\u003e\n    \u003c/textarea\u003e\u003cbr\u003e\n    \u003cinput type=\"submit\"\u003e\n\u003c/form\u003e\n```\n\n##### PHP-Curl\n```php\n$toList = 'example1@example.com,example2@example.com';\n$ccList = 'example1@example.com,example2@example.com';\n$subject = '测试邮件';\n$content = \u003c\u003c\u003cMAIL\n您好：\n测试\n详情点击\u003ca href=\"http://www.baidu.com\"\u003e《PHP是最好的语言》\u003c/a\u003e\u003cbr\u003e\n系统发送，请勿回复。\u003cbr\u003e\nMAIL;\n$filenameList = array(\n    '/tmp/1.png',\n    '/tmp/2.png',\n);\n$bodyContentType = 'text/html';\n\n$url = 'http://127.0.0.1:4000/mail';\n$method = \"POST\";\n$data['fromname'] = '系统邮件';\n$data['fromaddress'] = 'example@example.com';\n$data['tos'] = $toList;\n$data['ccs'] = $ccList;\n$data['subject'] = $subject;\n$data['content'] = $content;\nforeach(array_values($filenameList) as $key=\u003e$filename){\n    $data['attachment['.$key.']'] = new \\CURLFile(realpath($filename));\n}\n$data['body_content_type'] = $bodyContentType;\n\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, $url);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\ncurl_setopt($ch, CURLOPT_HEADER, 0);\ncurl_setopt($ch, CURLOPT_POST, 1);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, $data);\ncurl_setopt($ch, CURLOPT_TIMEOUT, 600);\n$r = curl_exec($ch);\ncurl_close($ch);\necho $r;\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixuancn%2Fmailservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flixuancn%2Fmailservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flixuancn%2Fmailservice/lists"}