shibbi3 Posted October 6, 2006 Share Posted October 6, 2006 hey everyone,ive been trying to create a form and use the mail() function to send out an email but I cant seem to get it to work.[code] $mail_header = "From: ".$name." <".$email.">\n"; $mail_header .= 'MIME-Version: 1.0' . "\r\n"; $mail_header .= "Content-Type: text/plain"; mail($mailto,$mail_subject,$text,$mail_header); [/code]$mailto, $mail_subject, $text, are all gathered from the form. All variables are all defined but when I click my send button it runs the code and nothing sends. I think its not connecting to a server. Im not really sure how to work this function.I was looking in the PHP.INI and I was just wondering if there is anything I need to setup in there for this to work?[mail function]; For Win32 only.SMTP = localhostsmtp_port = 25Thanks for any helpJoe Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/ Share on other sites More sharing options...
php_coder_dvo Posted October 6, 2006 Share Posted October 6, 2006 are you trying to run that script on youre local computer or on live server? Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105290 Share on other sites More sharing options...
shibbi3 Posted October 6, 2006 Author Share Posted October 6, 2006 i am currently trying it on my local server.but i eventually want it to run on a live server.is it 2 different setups?thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105304 Share on other sites More sharing options...
Tandem Posted October 6, 2006 Share Posted October 6, 2006 You need to configure php.ini to use a smtp server if you haven't already. I remember i had probelms with trying to do this on my local server.EDIT: It's under the module settings section of php.ini Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105306 Share on other sites More sharing options...
shibbi3 Posted October 7, 2006 Author Share Posted October 7, 2006 do you remember how to go about setting it up on a local network??So what is the purpose of the mail() function?? because when I run the code it still returns a true value saying it has sent it. Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105382 Share on other sites More sharing options...
karthikeyan_coder Posted October 7, 2006 Share Posted October 7, 2006 if you are getting problem while trying to send mails.. then use some smtp classes .. go to phpclasses.org then get one... Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105398 Share on other sites More sharing options...
baiju Posted October 7, 2006 Share Posted October 7, 2006 if you are using in iis. it wont work. it will work in online Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105407 Share on other sites More sharing options...
shibbi3 Posted October 7, 2006 Author Share Posted October 7, 2006 would this work on an local apache setup???how would you modify the php.ini file???im really new to this and cant seem to get this to work and i think its the smtp setup...im trying to relay it through gmail... so smtp.gmail.com port 465[code]<?php $to = 'joe12@gmail.com'; $subj = 'hi'; $body = 'hello'; $headers = "joe12@gmail.com\n"; $p5 = '-f joe12@gmail.com'; if(mail($to,$subj,$body,$headers,$p5)) { print "successfull"; } else { print "ERROR - not sent"; }?>[/code]plz heeelp Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105605 Share on other sites More sharing options...
redarrow Posted October 7, 2006 Share Posted October 7, 2006 you can only send email on a local server if you got a email sever setup but you can also setup the php.ini to use your current email provider but i say get a free email server set it up then tell php.ini what ip or domain it's atttached to.google it set up email server on windows. Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105610 Share on other sites More sharing options...
shibbi3 Posted October 7, 2006 Author Share Posted October 7, 2006 Alright. I've setup a mail server using this programhttp://www.code-crafters.com/abilitymailserver/I found out that port 25 is blocked. So I changed the port to 465 on my local mailserver which is not blocked by my ISP but im not sure if I can even use this port to send mail (ability mail server).I've run the code and it is still not working, and I dont think I am connecting to my SMTP server properly. (If anyone has a better program plz suggest it)All I am trying to do is to get the following to send an email to my gmail account from my local Apache/PHP5 setup.[code]<?php $to = 'joabchen@gmail.com'; $subj = 'hi'; $body = 'hello'; $headers = "joabchen@gmail.com\n"; $p5 = '-f joabchen@gmail.com'; if(mail($to,$subj,$body,$headers,$p5)) { print "successfull"; } else { print "ERROR - not sent"; }?>[/code]Does anyone know a solution to this problem?I think I am confused on the information flow with this problem. I dont see why I need an SMTP server setup and how the information is flowing from my ISP --> SMTP --> Gmail. If thats even how the information is being transferred.if anyone has a solution plzzzzzzzzzzz help!!! thank you. Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-105643 Share on other sites More sharing options...
php_coder_dvo Posted October 11, 2006 Share Posted October 11, 2006 the best thing is try it online :-) Quote Link to comment https://forums.phpfreaks.com/topic/23222-using-the-mail-function/#findComment-107246 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.