Jump to content


Photo

using the mail() function


  • Please log in to reply
10 replies to this topic

#1 shibbi3

shibbi3
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 06 October 2006 - 10:08 PM

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.


      $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);
	  



$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 = localhost
smtp_port = 25

Thanks for any help

Joe

#2 php_coder_dvo

php_coder_dvo
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationPhilippines

Posted 06 October 2006 - 10:40 PM

are you trying to run that script on youre local computer or on live server?

#3 shibbi3

shibbi3
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 06 October 2006 - 11:23 PM

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.

#4 Tandem

Tandem
  • Members
  • PipPipPip
  • Advanced Member
  • 251 posts

Posted 06 October 2006 - 11:26 PM

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

#5 shibbi3

shibbi3
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 07 October 2006 - 03:49 AM

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.

#6 karthikeyan_coder

karthikeyan_coder
  • Members
  • PipPipPip
  • Advanced Member
  • 201 posts

Posted 07 October 2006 - 06:27 AM

if you are getting problem while trying to send mails.. then use some smtp classes .. go to phpclasses.org then get one...

www.karthi.us

#7 baiju

baiju
  • Members
  • PipPip
  • Member
  • 28 posts

Posted 07 October 2006 - 06:57 AM

if you are using in iis. it wont work. it will work in online

#8 shibbi3

shibbi3
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 07 October 2006 - 05:47 PM

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


<?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";
    }
?>


plz heeelp

#9 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 05:50 PM

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.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#10 shibbi3

shibbi3
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 07 October 2006 - 07:23 PM

Alright. I've setup a mail server using this program

http://www.code-craf...litymailserver/

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.

<?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";
    }
?>

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.

#11 php_coder_dvo

php_coder_dvo
  • Members
  • PipPip
  • Member
  • 18 posts
  • LocationPhilippines

Posted 11 October 2006 - 12:54 AM

the best thing is try it online :-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users