Jump to content

not able to send mail. SMTP server..


jwalant

Recommended Posts

Hello i m newbie to PHP.  I am trying to host the website on my laptop but due to some configuration i cant send the emails through php script. I am trying send mail through mail() but not able to sent mail.

 

heres the code:

$to = "jwalant.baria@gmail.com";

$subject = "Hi!";

$body = "Hi,\n\nHow are you?";

if (mail($to, $subject, $body)) {

echo("<p>Message successfully sent!</p>");

} else {

echo("<p>Message delivery failed...</p>");

}

 

Output:

Message delivery failed..

 

I read the previous post here. but  I am not able to figure out what to do about it.

Can anyone tell me what setting i do in my php.ini? or any other that necessary settings require for this.

i don't have SMTP server on my laptop so is there any method from which i can setup the SMTP server on laptop.?

 

I use apache HTTP 2.2 and PHP 5.3.4

 

Rest of the website working correctly but only mail not working.

 

TY..!!

Link to comment
Share on other sites

Without a mail server you will need to use a third party script like PHPMailer (google it) to send mail via your internet providers (or any other provider really) host. PHP's mail function does not provide that ability to use authentication which any well configured mail server will require.

Link to comment
Share on other sites

Do i need mail server to run that simple program?

 

i uninstall the apache and php after going through various posts and video tutorials and i installed wamp server to test that program its giving me this 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\test.php on line 5

Message delivery failed...

 

My php.ini settings for smtp mail:

[mail function]

; For Win32 only.

; http://php.net/smtp

SMTP = localhost

; http://php.net/smtp-port

smtp_port = 25

 

; For Win32 only.

; http://php.net/sendmail-from

sendmail_from = you@yourdomain.com

 

is there anything wrong with the php.ini?

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.