Skip to content

Instantly share code, notes, and snippets.

@maninthemirror
Forked from s9011514/php-mail.php
Created February 20, 2016 10:14
Show Gist options
  • Save maninthemirror/9a1af860e175030b50b5 to your computer and use it in GitHub Desktop.
Save maninthemirror/9a1af860e175030b50b5 to your computer and use it in GitHub Desktop.
[PHP]使用Mail函式透過SMTP發信
<?php
$to =" yourmail@your.com "; //收件者
$subject = "test"; //信件標題
$msg = "smtp發信測試";//信件內容
$headers = "From: admin@your.com"; //寄件者
if(mail("$to", "$subject", "$msg", "$headers")):
echo "信件已經發送成功。";//寄信成功就會顯示的提示訊息
else:
echo "信件發送失敗!";//寄信失敗顯示的錯誤訊息
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment