Closed Thread Icon

Topic awaiting preservation: Php Emailing from a Form (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=12637" title="Pages that link to Topic awaiting preservation: Php Emailing from a Form (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Php Emailing from a Form <span class="small">(Page 1 of 1)</span>\

 
H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-05-2003 14:11

Hiya all, i'm currently doing an email from forms using some asp and an inbuild jmail thing on my hosts, im wondering if anyone has some suggestions on howto send an email from a form using PHP, preferably a html formatted email also. Any ideas or pointers? Is it possible to do this at all without relying on your host?

Thanks all!

Kriek
Maniac (V) Inmate

From: Florida
Insane since: Jul 2001

posted posted 03-05-2003 15:42

The mail() function allows you to send mail in PHP =)



__________________

Kriek says '[SYSTEMWIDE_MESSAGE] PHP Meetup'
What we do is never understood; only praised and blamed

Tyberius Prime
Paranoid (IV) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 03-05-2003 15:45

but of course it relies on your host providing smtp and having in configured in php.ini...

I believe you can set your own smtp.

Anyhow, it would be possible to do via the php sockets api withouta smtp-server, but most hosts deny those as well (and for a good reason).

So long,

Tyberius Prime

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 03-05-2003 16:34

H][RO: I couldn't recommend this more highly:
www.gurusnetwork.com/tutorials/php/contact_page/contactpage_1_en.html

___________________
Emps

FAQs: Emperor

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-05-2003 22:42

Thanks all ill take a look at that link emperor, unfortunately my host doesnt give s smtp's ill see how i go

Azazeal
Bipolar (III) Inmate

From:
Insane since: Jun 2002

posted posted 03-06-2003 23:28

<form action='?mode=mail' method='post'>
<table align='left'>
<tr>
<td align='right'>TO:</td>
<td><input type='text' name='to'></td>
</tr>
<td align='right'>SUBJECT:</td>
<td><input type='text' name='subject'></td>
</tr>
<tr>
<td align='right' valign='top'>MESSAGE:</td>
<td><textarea rows='10' cols='20' name='message'></textarea></td>
</tr>
<tr>
<td><input type='submit' value='send it'></td>
</tr>
</table>
</form>

<?php
if($_GET['mode']=='mail')
{
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
mail($to, $subject, $message);
echo "EMAIL SENT";
}
?>

Above is a very, very simple script put together in 5 minutes to show the mail() function.
Check to see if your host is using Linux or Unix, if so, then sendmail is what php will be using.
Or the easiest way is to create a script with the following:
<?php
phpinfo()
?>

Then check for a section that has the server info, this will let you know if it is Linux, Unix or Windows...and a path to the sendmail app, if it is installed.

Not sure if that helps out.


Azazeal
Bipolar (III) Inmate

From:
Insane since: Jun 2002

posted posted 03-06-2003 23:31

1

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-07-2003 00:19

Thanks Az, its a windows server, and they have a smtp for me to use from the server which is good.

Im not sure about the sendmail app tho, i thought mail() was a standard part of the php install from what i read, do they need something else as well?

Thanks.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 03-07-2003 00:40

No the php mail function is mostly an API configured with the php install to use the appropriate mailer utility



.:[ Never resist a perfect moment ]:.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-07-2003 01:08

Bummer, well thanks for that, i guess i better give it a try and check with them. Does phpinfo() tell you if it has been setup and installed at all?

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-07-2003 01:15

here is the php info for my host, i saw the sendmail_path = novalue =/ but further down it says sendmail support for windows enabled.

im not sure if the host has everything configured in a good way, they are still running v4.1.1 which im pretty sure has security issues too, i dont know enough about the php configuration to know if they have set things up the right way or not tho so if anyone notices anything strange please let me know.

I asked them if they would upgrade to a later php but i guess it requires a recomplie and everything so they didnt want to.



[This message has been edited by H][RO (edited 03-12-2003).]

Azazeal
Bipolar (III) Inmate

From:
Insane since: Jun 2002

posted posted 03-07-2003 05:28

Well, you can try the script I posted to see if it works...or just create a script like this:
<?php
mail(you@yourdomain.com,test,testmessage);
?>

replace `you@yourdomain.com` with your email address and load it up...see if it sends.
It may be reading that the smtp server is the localhost and may send it.
Also, you may want to take the phpinfo down as it is revealing everything about the server...just a security thing.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-12-2003 13:29

Thanks Az,

it all works a treat



H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-12-2003 23:55

on the same note, is there any way to get a response if the mail has been sent or not successfully? I'm not sure how this works, thanks again.

Zach
Neurotic (0) Inmate
Newly admitted

From:
Insane since: Mar 2003

posted posted 03-13-2003 03:10

goto http://php.net

type in mail in the functions box to search for, and find more info about basically everything you can do with this.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-14-2003 00:12

Yeh ive done this, i dont quite see anything about returning wether it was successful or not

kuckus
Bipolar (III) Inmate

From: Berlin (almost)
Insane since: Dec 2001

posted posted 03-14-2003 15:57

The mail() function retruns "true" if the mail could be sent and "false" if there was a problem, so you can use something along these lines:

code:
if (mail($recipient_email, $subject, $message, "From: $name <$email>")) {
echo "Success!";
}
else {
echo "Error!";
}



You'll find more on this in my GN tutorial which Emps mentioned above as well.

H][RO
Bipolar (III) Inmate

From: Australia
Insane since: Oct 2002

posted posted 03-15-2003 02:22

Thanks Kuckus, i have never really taken much advantage of funciton returns, a bad thing on my part, appreciate it.

« BackwardsOnwards »

Show Forum Drop Down Menu