Web Hosting Talk







View Full Version : cfm help with CFMAIL


desman
05-07-2003, 09:57 PM
Not to sure with cfm how to send an email just after a new insert to a sql server database. Anyway if someone could help that would be great, here is the code::

<cfquery datasource="sqlusers">
SET IDENTITY_INSERT NewMembers ON
INSERT INTO NetUsers (userid, Address , FirstName , Gender , JoinDate , LastName , Password , PostCode , State , Suburb , UserName )
VALUES (#NewUser#, '#form.Address#' , '#form.FirstName#', '#form.Gender#', '#dateformat(form.JoinDate,"yyyy-mm-dd")#', '#form.LastName#', '#form.Password#', '#form.PostCode#', '#form.State#', '#form.Suburb#', '#form.UserName#' )
SET IDENTITY_INSERT NewMembers OFF
</cfquery>

Need email to be sent to an admin here.

Also the email needs to extract the username and password to send to the admins.

Could someone help point me in the right direction?

Thanks

jb4mt
05-07-2003, 10:55 PM
This is from my web hosting services FAQ. Your mileage may vary:

How do I use the CFMAIL tag?
There are two things you need to do to make the CFMAIL tag work.

1. Make sure either the sender or the receiver is a valid email address in your domain. Don't use an alias if you are using the sender as the valid email account.

2. Always specify your VMS (virtual mail server) in the "server=" attribute of the mail tag.



<CFMAIL TO="someone@[somedomain]"
From="validemail@[yourdomain]"
Subject="[Your subject line]"
server="mail.[yourdomain]">

[email contents]

</cfmail>

Rich2k
05-08-2003, 04:36 AM
<cfmail to="youremail here" cc="anycchere" bcc="anybbchere" from="fromaddress" subject="Subject">
Body of email
</cfmail>


You don't have to specify a mail server if it's already done in the CF administrator or in your application.cfm

desman
05-08-2003, 04:45 AM
Thanks for your replies, one thing though how do I get the insert data into the email? The username & password of the new registered user?

Thanks again.

Rich2k
05-08-2003, 05:38 AM
In the same way you did inserting it into the database, just echo the CF string

e.g.
<cfmail to="youremail here" cc="anycchere" bcc="anybbchere" from="fromaddress" subject="Subject">
Your Username is: #form.LastName#
Your Password is: #form.Password#
</cfmail>

Note: Because you are doing this inside a CFML tag you don't need to use <cfoutput>

desman
05-08-2003, 11:37 PM
Thanks that worked perfectly.