Page 1 of 1

mail error

Posted: Wed Apr 04, 2007 3:58 am
by kpraman
i am getting 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

when i run the below code

Code: Select all

mail('mymail@gmail.com','mySubject','myMessage','From: kpraman@yahoomail.com');

Posted: Wed Apr 04, 2007 5:31 am
by Chris Corbyn
You don't have an SMTP server running on port 25?

Set the correct SMTP server in php.ini ;)

Posted: Wed Apr 04, 2007 5:34 am
by kpraman
is it possible to set it in the script?

Posted: Wed Apr 04, 2007 5:54 am
by Chris Corbyn

Code: Select all

ini_set("SMTP", "smtp.foo.tld");

Posted: Wed Apr 04, 2007 6:00 am
by kpraman

Code: Select all

ini_set("SMTP", "smtp.foo.tld");
mail('mymail@gmail.com','mySubject','myMessage','From: kpraman@yahoomail.com');
getting

Warning: mail() [function.mail]: Failed to connect to mailserver at "smtp.foo.tld" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in

Posted: Wed Apr 04, 2007 6:03 am
by onion2k
You'll need to change "smtp.foo.tld" to whatever the address of your SMTP server is.

Posted: Wed Apr 04, 2007 6:32 am
by kpraman
when i use

Code: Select all

phpinfo();
I am getting,

Directive Local Value Master Value

SMTP 25 localhost

smtp_port 25 25


i have tried

Code: Select all

ini_set("SMTP", "localhost");
I am getting same error

Posted: Wed Apr 04, 2007 6:34 am
by onion2k
If it's already set as localhost in the php.ini file then setting it to localhost with ini_set won't change anything. Hence the error continues to appear. You need to change it to one that works.

Posted: Wed Apr 04, 2007 7:34 am
by Chris Corbyn
Who is your ISP? Your ISP should have an SMTP server set up for you to configure things like this for. It's the same setting you'd add to Outlook or Thunderbird.

Posted: Wed Apr 04, 2007 8:08 am
by kpraman
In the outlook's internet account's value is mail.myserver.com

Posted: Wed Apr 04, 2007 8:25 am
by Chris Corbyn
Good. So what have you tried?

Posted: Wed Apr 04, 2007 8:56 am
by kpraman

Code: Select all

ini_set("SMTP", "mail.myserver.com"); 
mail('mymail@gmail.com','mySubject','myMessage','From: kpraman@mail.myserver.com');
Warning: mail() [function.mail]: SMTP server response: 550-(phpserver) [122.167.128.101]:2555 is currently not permitted to relay 550-through this server. Perhaps you have not logged into the pop/imap server 550-in the last 30 minutes or do not have SMTP Authentication turned on in your 550 email client.

Posted: Wed Apr 04, 2007 10:06 am
by Chris Corbyn
Ah, sweet PopB4Smtp. That sucks. You really do *have* to use Swift Mailer now.

http://www.swiftmailer.org/
http://www.swiftmailer.org/wikidocs/v3/smtpauth (Last section near the bottom)

Posted: Wed Apr 04, 2007 10:21 am
by kpraman
Thanx, i will try it.