Jump to content

PHP mail() Function I have got one question


kee2ka4

Recommended Posts

Hi! I am using a mail() function in one of my php code. However I have getting the following error:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\Car_Project\Registration\Testingtutorial\register.php on line 121

I am using Localhost, Could anyone please tell me what I have done wrong or what setting I am required to change...

Thanks for any Help

Regards,
Keetan
Link to comment
Share on other sites

Thanks for your reply, I have looked into the mail() function in php.ini and this is what there is:

[mail function]
; For Win32 only.
SMTP = localhost

; For Win32 only.
;sendmail_from = me@example.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_paramaters =

Could you tell me what I need to change in that?

Also I have found three files with php.ini extension these are php.ini-recommended (c:\wamp\php), php.ini (c:\wamp\apache2\bin), and php.ini-dist (c:\wamp\php) do I have to change the settings in all of them?

Thanks for your Help...
Regards,
Kee2ka4
Link to comment
Share on other sites

You need to setup PHP to a an SMTP server. Youm might be able to use your ISPs maiul server if they have an smtp server, so thing like smtp.ispname.com

The defualt SMTP port is fine, as most SMTP servers run on port 25.

NOTE: If your isp requires you to be logged into to send an email to the smtp server, you wont be able to use the mail function. As the mail function doesnt support any authentication protocols.
Link to comment
Share on other sites

Hi! Thanks for all the Responses! Could anyone point me to the Direction as to how to Install an SMTP server locally? I don't even know if I have an SMTP server. Sorry I am quite new to all this.  ::)

Btw my ISP is pipex and I am using my local host to view my php files and I am using Apache! I just want this mail() to work for me to proceed!

Thanks..
Link to comment
Share on other sites

I have changed the smtp from localhost to my isp smtp address, however I still get the same error message. The settings I am changed in php.ini is:

[mail function]
; For Win32 only.
SMTP = smtp.dsl.pipex.com
smtp_port = 25

After changing the smtp from localhost to smtp.dsl.pipex.com I still get the same error message. The error message I get is

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\Car_Project\Registration\Testingtutorial\register.php on line 121

I have gone through many tutorials and researched google pages but didn't get anywhere... Some say to install an smtp server, I even tried that and its just not working

Could anyone help me please? I really can't proceed without sorting this error out... Please give me some light to my problem...

Regards,
Kee2ka4....
Link to comment
Share on other sites

Hi! Thanks for your reply wildteen.... You were right I didn't restart my server but now the error message has changed... now it says the following...

Warning: mail() [function.mail]: SMTP server response: 501 Bad address syntax in C:\wamp\www\Car_Project\Registration\Testingtutorial\register.php on line 121


The mail() function code on line 121 is:

[quote] mail($email_address, $subject, $message, "From: MyDomain Webmaster<me@example.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
[/quote]

Any idea's what might be wrong?

Cheeerss
Link to comment
Share on other sites

The $email_address seems to be fine cause it does successfully add the details to the database! The $email_address is the address that I enter in a form, its just a normal hotmail email account that I enter. I have even tried @yahoo.com @gmail.com and non of them work...?

Any other cluess... if nothing works then I will have to upload it on a webhosting company, but i would really prefer to work on my localhost.... ::)
Link to comment
Share on other sites

Yes  ;D! I have sorted out the Problem! It took me one whole day lololol ! What I did is I stopped using mail () function and instead replaced it with PHPMailer, this is a php class for sending out emails. Anyone that is having problems with mail(), go throught this tutorial, its is really helpfull...

http://www.phpfreaks.com/tutorials/130/0.php

Understand the PHPMailer class and then apply it into your code! If you want your webform to send emails, and do many other things, use phpmailer, it will work perfectly. The only thing u need to change is the smtp address in the php.ini file. My ISP is pipex and therefore my SMTP = smtp.dsl.pipex.com. Thats it!

Anyways.. I am off, thanks for all the help today!

Regards, Kee2ka4
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.