Computing.Net > Forums > Web Development > cant send mail from localhost

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

cant send mail from localhost

Reply to Message Icon

Name: raviepic3
Date: November 16, 2008 at 00:20:46 Pacific
OS: XP
CPU/Ram: enough
Product: 915gav
Comment:

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 220, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in temp.php on line 53

Warning: Cannot modify header information - headers already sent by (output started at temp.php:53) in temp.php on line 55

51: if(xxxxxxx)
52: {
53: mail($to,$sub,$mesNamePass);
54: $domain="xxx.com";
55: header('Location:'. $domain);
56: }

programming newbie :)



Sponsored Link
Ads by Google

Response Number 1
Name: Elinor
Date: November 18, 2008 at 06:32:23 Pacific
Reply:

Hi,

Do you have a mail server installed on localhost? If not you should configure your mail settings in PHP.ini to 'point' to your mail server.

It should look something like:
SMTP = smtp.xxxxx.xxx
smtp_port = 25

sendmail_from = xxxx@xxxxx.xxx

Once the mail server is properly configured, you may want to silence the 'mail' function and handle errors (sort of), by using something like:
if (@mail(...)) {
header('Location:'. $domain);
}
else {
echo "Something went wrong, please try again in a few minutes or contact support at: ..."
}

Hth,

Elinor

Elinor Hurst
http://elinorhurst.blogspot.com


0

Response Number 2
Name: raviepic3
Date: November 18, 2008 at 07:51:07 Pacific
Reply:

the above error was rectified...now its not showing me any error but the mail is not getting passed but goes to next stage of ma program ie. geting routed to another page.

below are php.ini editions done by me


SMTP = smtp.attwireless.net
smtp_port = 25

sendmail_from = sample@sample.com

if any more procedures i have to follow ?

programming newbie :)


0

Response Number 3
Name: Elinor
Date: November 18, 2008 at 12:41:35 Pacific
Reply:

Hi,

Is if (mail(...)) returning true?

I expect the server requires authentication in order to relay. If that is the case, you may want to investigate the following article, which explains how to do this using the PEAR mail package: http://email.about.com/od/emailprog...

Hth,

Elinor

Elinor Hurst
http://elinorhurst.blogspot.com


0

Response Number 4
Name: raviepic3
Date: November 18, 2008 at 21:28:55 Pacific
Reply:

hey that really helped

im using mime::mail package

all procedures are done but yet i cant pass the mail to inbox.

the code dosent even show any error but mail is not geting passed

programming newbie :)


0

Response Number 5
Name: raviepic3
Date: November 18, 2008 at 21:39:09 Pacific
Reply:

here is my code


test
<?php
ini_set ("display_errors", 1);


$your_html_message = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Hello World!</title>
</head>
<body>


Hello World!</p>
</body>
</html>' .
'.';
require_once ("Mail.php");
require_once ("Mail/mime.php");
$recipients = 'User <sen.newjob@gmail.com>';
$headers["From"] = 'User <sen.newjob@gmail.com>';
$headers["To"] = 'User <sen.newjob@gmail.com>';
$headers["Subject"] = "Ready To Eat Pears";
$crlf = "\n";
$mime = new Mail_mime($crlf);

$mime->setHTMLBody($your_html_message);
$message = $mime->get();
$headers = $mime->headers($headers);
$params["host"] = 'smtp.gmail.com';
$params["auth"] = TRUE;
$params["auth"] = PLAIN;
$params["username"] = 'sen.newjob@gmail.com';
$params["password"] = 'xxxx';
$params["localhost"]= 'smtp.gmail.com';
$params["debug"] = "True";
Mail::factory method
$mail_message =& Mail::factory('smtp', $params);
$mail_message->send ($recipients, $headers, $message);
?>

if i execute this i get something like this in my browser

test DEBUG: Recv: 220 mx.google.com ESMTP w12sm339947tib.10 DEBUG: Send: EHLO smtp.gmail.com DEBUG: Recv: 250-mx.google.com at your service, [122.164.170.210] DEBUG: Recv: 250-SIZE 35651584 DEBUG: Recv: 250-8BITMIME DEBUG: Recv: 250-STARTTLS DEBUG: Recv: 250 ENHANCEDSTATUSCODES DEBUG: Send: RSET DEBUG: Recv: 250 2.1.5 Flushed w12sm339947tib.10 DEBUG: Send: QUIT DEBUG: Recv: 221 2.0.0 closing connection w12sm339947tib.10


but my mail not geting reached to my inbox :(


plz help me

programming newbie :)


0

Related Posts

See More



Response Number 6
Name: Elinor
Date: November 19, 2008 at 14:34:36 Pacific
Reply:

Hi again,

Mmm... Not sure.

This:
$params["auth"] = TRUE;
$params["auth"] = PLAIN;
looks a little weird though.

Shouldn't that simply be:
$params["auth"] = true;
?

I would also suggest trying to use only the email address in $to, $from, etc. as I have found the 'long' notation can cause problems on some systems.

Another thought: have you tried sending something really simple like : subject 'Ready to eat pears' and message 'Ready to eat pears' ?

hth,

Elinor

Elinor Hurst
http://elinorhurst.blogspot.com


0

Response Number 7
Name: raviepic3
Date: November 19, 2008 at 20:42:06 Pacific
Reply:

hi brother,

thanks for burning ur valuable time in guiding me

the scenario is :

i am trying to send a mail via a remote smtp server from a webserver(localhost) using wamp people say this is not possible because the smtp servers will not accept connections from outside port 80(http) to their port 25(smtp) to avoid abusing..


is this true ???


and regarding sending a simple mail...if some message like "i like to eat pears" gets apssed then the html also shld do ryt ?

nothing gets away :(

i did the changes u said no effect..


i use this because to put md5-sum when needed

$params["auth"] = PLAIN;

neways now i commented that too..

programming newbie :)


0

Response Number 8
Name: Elinor
Date: November 20, 2008 at 02:26:40 Pacific
Reply:

Hi,

Not sure I like being called 'brother', perhaps not being a man has something to do with that... ;-)

Yes obviously most SMTP servers are closed to relaying otherwise get abused by spammers, and so on and so forth.

Your best bet would be to use a mail server that your hosting solution hopefully provides for you. In that case they should give you the relevant information so that you can send from your hosted site through their mail server.

Hth,

Elinor

Elinor Hurst
http://elinorhurst.blogspot.com


0

Response Number 9
Name: raviepic3
Date: November 22, 2008 at 08:04:34 Pacific
Reply:

oh...

sorry about calling you brother Elinor..its just i address everybody like that...sory if that discomforted you...


and i identified the problem dude...it was abt the smtp i used....gmail required connection through ssl whereas i didnt....

changed smtp and it worked...

thanks for your time again :)

programming newbie :)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: cant send mail from localhost

i want send a mail from unix to my outlook www.computing.net/answers/webdevel/i-want-send-a-mail-from-unix-to-my-outlook/4193.html

Windows Live/OptOnline Sending Mail www.computing.net/answers/webdevel/windows-liveoptonline-sending-mail/3885.html

sending SMS from website www.computing.net/answers/webdevel/sending-sms-from-website/237.html