This is a discussion on "Sending email" within the PHP Forum section. This forum, and the thread "Sending email are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Sending email
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Sending email
Right i have been searching and searching, i have found out that php is the language to use to work with forms and databases. My question is how do you send a email using php i have tried the mail() function and it doesnt work!!
|
|
|
|
|||
|
Re: Sending email
Have a look at http://1ontheweb.net/1ontheweblog.html and download the two files associated with the 'Fighting back against the spam' article that I wrote a while back.
There is a file with all the code you need with explanations of what is happening. Work through that and you will know how to create forms with php and use its mail() function. Any queries, come back here and ask. |
|
|||
|
Re: Sending email
Show us your code.
|
|
|||
|
Re: Sending email
I have been reading and found my mail() code was wrong, it now sends a email, but it is labeled as junk email. I have been reading in the forums and seen someone had the same problem but you thought he was a spammer so no answer is given. So hopefully if i give you the reason why i want this auto email you will help me, i am building a form and when this form is filled out a email will be sent to me with the answers from the form.
Here is my php code now <?php if(mail("********@hotmail.com","Test","This is to test the PHP MAIL()", "From: info@mysite.com")) print('<p>WORKED</p>'); else print('<p>NOT WORKED</p>'); ?> i originally had no From: and thought that this might be why its labeled as junk, but obviously not. |
|
|||
|
Re: Sending email
It won't be being labelled as 'junk' by the php processing. This is being done by someone's email filtering. Hotmail or yours. I would guess this is most likely happening because of your subject, 'test'. Try a real subject and some proper content and see what happens. |
|
|||
|
Re: Sending email
I have done as you said but no change still being labeled as junk, but i have found that i can labelthe email address as not being junk email and it can get through, at last. But if i was unable to label it as not being junk, as i may have to send it to another email address is their anything i can do.
|
|
|||
|
Re: Sending email
The following code is basic and may well get picked to bits but it works. You'll need a mail server for it to run. You'll have to put a valid email address at the "$MailToAddress = "put the recipients email here" part of the code 2 thirds down. Hope this works OK.
<html> <head> <title>Email Jagprops</title> <link rel="stylesheet" type="text/css" //href="css3.css"/> </head> <body> <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <p style="line-height: 100%; margin: 0"> <img border="0" src="star.gif" width="206" height="43" vspace="7"> <p style="line-height: 100%; margin: 0"> <input name="youremail" type="text" size="35"/> <font color="#800000" size="2" face="Century Gothic"><b>your email</b></font> <p style="line-height: 100%; margin: 0"><font color="#800000" size="2" face="Century Gothic"><b><br> <input name="subject" type="text" size="35"/> subject</b></font> </p> <p style="line-height: 100%; margin: 0"><br> <TEXTAREA NAME="comments" ROWS="20" cols="40">enter your message/query here</TEXTAREA> <br> </p> <input type="submit" value = submit /> </form> <? $MailFromAddress = $_GET['youremail']; $MailSubject = $_GET['subject']; $Message= $_GET['comments']; $MailToAddress = "put the recipients email here"; if (!$MailFromAddress) { $MailFromAddress = "SENDERS@ADDRESS.GOES.HERE"; } else{ mail( "$MailToAddress", "$MailSubject", "$Message", "From: $MailFromAddress"); echo "Thank you, your email has been received."; } ?> <br><br> <a href="/"><font size="2" face="Century Gothic" color="#000080">Home Page</font></a><br><br> </body> </html> |
![]() |
| Tags |
| sending, email |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP email form not sending email | Kurt | PHP Forum | 1 | Oct 12th, 2007 04:26 |
| sending email fails | flann | Hosting & Domains | 1 | Feb 17th, 2007 23:38 |
| sending email arrays with php | ppgpilot | PHP Forum | 2 | Jan 25th, 2007 16:49 |
| Email + attachment sending | manzil | PHP Forum | 1 | Aug 4th, 2006 13:40 |
| Sending Email | Paul00000001 | JavaScript Forum | 3 | Jul 29th, 2006 03:16 |