快轉到主要內容

Centos7 安裝 Postfix 並配置 mailgun 服務

Y Cheung
作者
Y Cheung
Blogger, Programer & Traveler.
目錄

上次Ubuntu主機配置好郵件服務後沒有及時寫下來備份,結果這次重裝主機就又去search了一番 ,浪費時間,唉~ 畢竟不熟練(我又不是網管又不是運維,哼

註冊第三方郵件服務
#

這兩個服務YCHEUNG都有用過,感覺差不多,本篇就只講 mailgun 啦!

註冊好之後,可以新添加自定義域名(需驗證),也可以使用網站默認提供的一長串地址,免費賬號限制每月發送的郵件數,不過作為個人主機發發系統郵件什麼的,免費額度足夠了。

mailgun domains

選擇你要使用的domain查看詳細信息:

Mailgun domain settings detail

關鍵記錄下Default SMTP Login 和 Default Password,之後配置Postfix的時候會需要用到。

安裝並配置Postfix
#

  • 安裝Postfix
1yum install postfix
  • 編輯Postfix配置文件

順手的話可以設置一下 hostname 和 domainname (非必須)

1# /etc/postfix/main.cf
2
3relayhost = [smtp.mailgun.org]:587
4smtp_sasl_auth_enable = yes
5smtp_sasl_password_maps = static:剛才記下來的login:剛才記下來的Password
6smtp_sasl_security_options = noanonymous

參考:https://documentation.mailgun.com/docs/mailgun/user-manual/sending-messages/#send-via-smtp

  • 重啟Postfix服務
1service postfix restart

測試
#

如果你尚未安裝mailx可以先執行以下命令:

1yum install mailx

測試發郵件

1echo "Test mail from mailgun" | mail -s "Test Subject" [email protected] 

成功的話,會在你的指定郵箱中受到郵件,也可以在 mailgun 的log頁面中看到日誌消息。

Mailgun Log

相關文章

自动备份网站文件及数据库到dropbox

·508 字·2 分鐘
環境 # 第三方资源:Dropbox Uploader 系统环境:Ubuntu x64 操作步驟 # 在dropbox官方创建一个新的应用「 Dropbox API App」,获得APP key和APP secret 在终端上下载并执行本文开头所引用的第三方资源 1curl "https://raw.githubusercontent.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh" -o dropbox_uploader.sh 2sudo $chmod +x dropbox_uploader.sh 3sudo $./dropbox_uploader.sh 按照屏幕提示输入APP key和APP secret,许可权限类型选择a,确认后在浏览器中打开终端给出的token链接,完成验证

FEDORA安装electron-builder报错make:g++:命令未找到之解决

·354 字·1 分鐘
系统环境: Fedora 24 Node v4.5.0 NPM v2.15.9 NPM安装electron-builder报错 # 1$npm install electron-builder --save=dev 2npm WARN package.json [email protected] No repository field. 3npm WARN package.json [email protected] No README data 4 5> [email protected] install /var/www/html/test/node_modules/dev/node_modules/inotify 6> node-gyp rebuild 7 8make: Entering directory '/var/www/html/test/node_modules/dev/node_modules/inotify/build' 9 CXX(target) Release/obj.target/inotify/src/bindings.o 10make: g++:命令未找到 11inotify.target.mk:97: recipe for target 'Release/obj.target/inotify/src/bindings.o' failed 12make: *** [Release/obj.target/inotify/src/bindings.o] Error 127 13make: Leaving directory '/var/www/html/test/node_modules/dev/node_modules/inotify/build' 14gyp ERR! build error 15gyp ERR! stack Error: `make` failed with exit code: 2 16gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/lib/build.js:276:23) 17gyp ERR! stack at emitTwo (events.js:87:13) 18gyp ERR! stack at ChildProcess.emit (events.js:172:7) 19gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) 20gyp ERR! System Linux 4.7.4-200.fc24.x86_64 21gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" 22gyp ERR! cwd /var/www/html/test/node_modules/dev/node_modules/inotify 23gyp ERR! node -v v4.5.0 24gyp ERR! node-gyp -v v3.4.0 25gyp ERR! not ok 26npm WARN optional dep failed, continuing [email protected] 27npm WARN deprecated [email protected]: This package is deprecated. Use Object.assign. 28npm WARN optional dep failed, continuing [email protected] 29npm WARN optional dep failed, continuing [email protected] 30npm ERR! Linux 4.7.4-200.fc24.x86_64 31npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "electron-builder" "--save=dev" 32npm ERR! node v4.5.0 33npm ERR! npm v2.15.9 34npm ERR! code ELIFECYCLE 35 36npm ERR! [email protected] install: `node-gyp rebuild` 37npm ERR! Exit status 1 38npm ERR! 39npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'. 40npm ERR! This is most likely a problem with the inotify package, 41npm ERR! not with npm itself. 42npm ERR! Tell the author that this fails on your system: 43npm ERR! node-gyp rebuild 44npm ERR! You can get information on how to open an issue for this project with: 45npm ERR! npm bugs inotify 46npm ERR! Or if that isn't available, you can get their info via: 47npm ERR! 48npm ERR! npm owner ls inotify 49npm ERR! There is likely additional logging output above. 50 51npm ERR! Please include the following file with any support request: 52npm ERR! /var/www/html/test/npm-debug.log 解决方法: # 安装G++ $sudo dnf install gcc-c++

Drupal7中自定义表格输入

·1240 字·3 分鐘
Drupal默认的节点表单(entity form)输入有时候并不能满足我们的需求,比如我想做一个类似excel表格输入形式的表单呢? = DEMO点这里 (PS. 用Pantheon的sandbox做了一个随意折腾的drupal站点,真的是折腾死我了= =) 首先,新建一个自定义模块,在你的*.module文件中hook_menu() 指定一个页面路径,设置页面调用表单,比如这样:

Drupal7 中Restful模组应用简单介绍

·1918 字·4 分鐘
安装并启用Restful Module # Restful 2.x 下载 drush 安装 drush dl restful, drush en restful 自定义RESTFUL API模组 # 可参考restful里的范例 sites/all/modules/restful/modules/restful_example 或者测试文件内容 sites/all/modules/restful/tests 模组文件结构 # 1custom_restfulapi/ 2├─ src/ 3│ ├─ Plugin/ 4│ │ ├─ resource/ 5│ │ │ ├─ entity/ 6│ │ │ │ ├─ Testentity__1_0.php 7├─ custom_restfulapi.info 8├─ custom_restfulapi.module API RESOURCES要放在src/Plugin下。 *.info 和 *.module 的内容跟其他自定义模组的相差无几,方法一样,此处从略。

Krpano Panoramic Video Embed Wordpress plugin

·380 字·1 分鐘
krpano 做 Panoramic Video 的時候很麻煩(官網說明太簡單),要自己改一堆東西然後上傳,然後再用iframe的方式在wordpress 文章或者頁面中加載,一整個就煩透了。於是用空閒時間順手做了這個插件,稍微簡化了一下流程。 軟體版本: # Wordpress 版本 4.3.1 Krpano 版本 1.18 插件下載: # Github BOX 安裝插件: # 文件解壓縮至 /wp-content/plugins/ 將你購買的krpano程序中相應的文件替換掉本插件中的文件,包括 /krpano/krpano.js 和 /krpano/krpano.swf ,(本插件中的文件源自未授權demo版,請自行購買授權)。 登錄wordpress後台,並激活插件 使用插件: # 將 Panoramic Video 壓制成 1920x960 和 1024x512 尺寸,推薦WEBM格式或MP4格式 製作 Panoramic Video 封面縮略圖兩張,尺寸分別為1920x960 像素 和 1024x512 像素 將視頻和圖片通過FTP上傳至 /krpano/video 文件夾中 點擊編輯器上的按鈕(如下圖所示)在需要嵌入Panoramic Video的地方插入代碼 務必完整填寫完所有表單(如下圖示) 5. 如需自定義XML,文件放在 /krpano/xml 中