Jump to content

using the mail() function


shibbi3

Recommended Posts

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

Thanks for any help

Joe
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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

http://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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.