Generating automatic emails

This is a discussion on "Generating automatic emails" within the PHP Forum section. This forum, and the thread "Generating automatic emails are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Nov 26th, 2006, 09:08
Junior Member
Join Date: Nov 2006
Location: UK
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Generating automatic emails

Hi all
just been asking on the html forum if it is possible to record someones email address on a web page and then send them an email. They suggested that it would be best to use PHP, so i am asking the question here.
I want to have a box on the web page that people can enter their email address into and when they click send.
A standard email is then sent asking the person to confirm that they want to join the mailing list.
Now I understand that PHP can add the email address to the database, but can PHP generate the reply email and send it automatically?

DennisK
__________________
The one stop toy shop: www.toysofamerica.
Reply With Quote

  #2 (permalink)  
Old Nov 26th, 2006, 13:50
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Generating automatic emails

Absolutely, that's the kind of thing php does best. I'd probably advise to learn enough php so that you know the basics, though, before you plug in a script.

It will also store the member's name and email address (password, shoe size, whatever) automatically in a database and generate the mailout to all members.

Last edited by masonbarge; Nov 26th, 2006 at 13:54. Reason: added infor
Reply With Quote
  #3 (permalink)  
Old Nov 26th, 2006, 14:32
Junior Member
Join Date: Nov 2006
Location: UK
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Red face Re: Generating automatic emails

Is there a name for these types of script?

DennisK
__________________
The one stop toy shop: www.toysofamerica.
Reply With Quote
  #4 (permalink)  
Old Nov 26th, 2006, 21:47
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Generating automatic emails

You could call it a 'mail' script if you like.

Seriously, you write the script to do what you need it to do.

Go to http://php.net and look at the 'mail' function as your starting point. But as Mason has already said, there is a lot more to it than that.

You need to consider validation, security from sql injection attacks, etc.

You've got some reading to do.
Reply With Quote
  #5 (permalink)  
Old Nov 26th, 2006, 23:09
Junior Member
Join Date: Nov 2006
Location: UK
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Re: Generating automatic emails

What is an "sql injection attack"?
DennisK
__________________
The one stop toy shop: www.toysofamerica.
Reply With Quote
  #6 (permalink)  
Old Nov 27th, 2006, 05:00
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Generating automatic emails

An SQL injection attack is where a user of your form enters a piece of SQL code into it, and wraps it in special characters in such a way that the data entered doesn't get used for the purpose you had intended - it gets used to corrupt or destroy your database.

For example, if your form returns to $_REQUEST[message] and you write
INSERT into msgtab (message) values ("$_REQUEST[message]")
in your code, then without the appropriate precautions I could enter
Got you"); delete his database;
or words to that effect ... and that would be a nasty injection attack.

Note that most copies of PHP are configured with magic quotes on to insure against this kind of hole being left by newcomers to coding, and that my example - quite intentionally - doesn't exactly attack; rather, it shows the principle
Reply With Quote
  #7 (permalink)  
Old Nov 27th, 2006, 12:21
Junior Member
Join Date: Nov 2006
Location: UK
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Re: Generating automatic emails

WOW....this very, very bad.

I just want to see if I have this right.

I have an sql database on my server.

Now, no one can access this database unless they have the password.

But what your saying is, if I make a request for some data, and instead of someone inputing, for example their email address, they could put in some special code which when returned to the database gets stored.

But these charcters are so special that when the database gets to them it crashes the sql interpreter in such a manner that it could crash through the database and delete all your data.

Is that correct???

DennisK
__________________
The one stop toy shop: www.toysofamerica.
Reply With Quote
  #8 (permalink)  
Old Nov 27th, 2006, 14:02
Reputable Member
Join Date: Oct 2006
Location: UK
Age: 25
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cullinanweb Send a message via Skype™ to cullinanweb
Re: Generating automatic emails

When u have learnt php, the normal method for email confirmation (correct me if i am wrong) is by adding the session id into the database with the email and send the address you want to confirm with the session id as a get command (after a "?sid=___________)" this would then add into the database (another field) that says the user wants to recieve emails and u only send to conformed ones.
Reply With Quote
  #9 (permalink)  
Old Nov 27th, 2006, 17:59
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Generating automatic emails

OK ... let me clarify a couple of things:

1. If a web site and its applications are set up correctly, anyone can access a database that's there is the manner chosen by the programmer, and that's probably without knowing the password. Heck - we record the colour and font size requirements of our users chosen on one visit and remember them for their next visit ... and they don't even need to know there's a database there. The problems occur only when the programming isn't properly set up or well thought out and uers find a way of doing something beyond what is prudent.

2. On current defaults, PHP has something called "magic quotes" switched on, which means that if you don't know what you're doing you're unlikely to accidentally allow a MySQL injection attack. (If, however, you've added a stripslashes to get rid of irritating extra quotes you may have left yourself open).

In summary, there's an awful lot of sites out there (and a lot of awful sites) and they don't fall foul of injection attacks every day. It's something to learn about, be trained on, be aware of though ... as there are many flavours and varients.

Session ids are really a different subject ....
Reply With Quote
  #10 (permalink)  
Old Nov 28th, 2006, 10:49
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Generating automatic emails

Graham, that's the first time I've ever heard that. So you advise leaving magic quotes enabled unless/until you are 100% competent in escape technique and theory?

Like me - I understand the basics of escapes in php/mysql but not enough to know what it is I don't know. Maybe I'll ensure magic quotes is enabled and take out all my stripslash modules.
Reply With Quote
  #11 (permalink)  
Old Nov 28th, 2006, 11:38
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Generating automatic emails

Yes, unless you're confident in what you're coding, you should have magic quotes on. You can always striplslashes part of something you're echoing if you need to, though even that isn't the whole story. I've actually got quite a long piece that goes into this but it doesn't really fit the forum / question and answer format for pasting in here.
Reply With Quote
Reply

Tags
generating automatic emails

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating a CSS Template from HTML dhochee Web Page Design 2 Apr 3rd, 2007 18:06
Dodgy Emails! bruno89 Webforumz Cafe 10 Apr 2nd, 2007 12:01
Generating a PDF File SephirGaine Web Page Design 9 Aug 22nd, 2006 12:12
Generating ID or Session Problem? Options chlad Classic ASP 2 Aug 21st, 2006 11:47
Website Emails joshcxa Web Page Design 3 Jul 21st, 2005 23:12


All times are GMT. The time now is 01:53.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43