coldfusion send email (1): only text or html
Coldfusion 發送簡易電子郵件的方法:
使用 cfmail 標籤指令
純文字模式
<cfmail
to="recipient1@mail.domain.com,recipient2@mail.domain.com"
from="sender@mail.mydomain.com"
subject="顧客意見反映"
server="mail.mydomain.com"
username="MySmtpAccount"
password="MyPassword"
type="text">
本訊息由網頁『顧客意見』發出,請勿回覆此信件。#chr(13)##chr(10)#
發訊時間 :#DateFormat(NOW() , 'yyyy/mm/dd')# #TimeFormat(NOW() , 'HH:mm:ss')#
發訊人姓名:#SenderName##chr(13)##chr(10)#
發訊人電話:#SenderTEL##chr(13)##chr(10)#
發訊人郵件:#SenderMail##chr(13)##chr(10)#
= = = = = = = = = = = = = = = = = = = =
#MailBodyText#
</cfmail>
HTML模式
<cfmail
to="recipient1@mail.domain.com,recipient2@mail.domain.com"
from="sender@mail.mydomain.com"
subject="顧客意見反映"
server="mail.mydomain.com"
username="MySmtpAccount"
password="MyPassword"
type="html">
<div style="width:700px;margin:auto 10px;font-size:16px;background-color:##FFC;">
<span style="color:##060;">本訊息由網頁『顧客意見』發出,請勿回覆此信件。</span><br />
發訊時間 :<span style="color:##00F;font-weight:700;">#DateFormat(NOW() , 'yyyy/mm/dd')# #TimeFormat(NOW() , 'HH:mm:ss')#</span><br />
發訊人姓名:<span style="color:##00F;font-weight:700;">#SenderName#</span><br />
發訊人電話:<span style="color:##00F;font-weight:700;">#SenderTEL#</span><br />
發訊人郵件:<span style="color:##00F;font-weight:700;text-decoration:underline;">#SenderMail#</span><br />
= = = = = = = = = = = = = = = = = = = = = = = = = =<br />
<b><pre>#MailBodyText#</pre></b>
</div>
</cfmail>
cfmail可以直接使用SMTP伺服器發送郵件,所以只要你有架設標準SMTP伺服器就可以發信了。
from 沒有一定要與自己的smtp有關聯,所以可以寄偽信(汗),當然,這樣很容易被對方郵件主機反查失敗而SPAM掉。
使用 cfmail 標籤指令
純文字模式
<cfmail
to="recipient1@mail.domain.com,recipient2@mail.domain.com"
from="sender@mail.mydomain.com"
subject="顧客意見反映"
server="mail.mydomain.com"
username="MySmtpAccount"
password="MyPassword"
type="text">
本訊息由網頁『顧客意見』發出,請勿回覆此信件。#chr(13)##chr(10)#
發訊時間 :#DateFormat(NOW() , 'yyyy/mm/dd')# #TimeFormat(NOW() , 'HH:mm:ss')#
發訊人姓名:#SenderName##chr(13)##chr(10)#
發訊人電話:#SenderTEL##chr(13)##chr(10)#
發訊人郵件:#SenderMail##chr(13)##chr(10)#
= = = = = = = = = = = = = = = = = = = =
#MailBodyText#
</cfmail>
HTML模式
<cfmail
to="recipient1@mail.domain.com,recipient2@mail.domain.com"
from="sender@mail.mydomain.com"
subject="顧客意見反映"
server="mail.mydomain.com"
username="MySmtpAccount"
password="MyPassword"
type="html">
<div style="width:700px;margin:auto 10px;font-size:16px;background-color:##FFC;">
<span style="color:##060;">本訊息由網頁『顧客意見』發出,請勿回覆此信件。</span><br />
發訊時間 :<span style="color:##00F;font-weight:700;">#DateFormat(NOW() , 'yyyy/mm/dd')# #TimeFormat(NOW() , 'HH:mm:ss')#</span><br />
發訊人姓名:<span style="color:##00F;font-weight:700;">#SenderName#</span><br />
發訊人電話:<span style="color:##00F;font-weight:700;">#SenderTEL#</span><br />
發訊人郵件:<span style="color:##00F;font-weight:700;text-decoration:underline;">#SenderMail#</span><br />
= = = = = = = = = = = = = = = = = = = = = = = = = =<br />
<b><pre>#MailBodyText#</pre></b>
</div>
</cfmail>
cfmail可以直接使用SMTP伺服器發送郵件,所以只要你有架設標準SMTP伺服器就可以發信了。
from 沒有一定要與自己的smtp有關聯,所以可以寄偽信(汗),當然,這樣很容易被對方郵件主機反查失敗而SPAM掉。
留言