mail error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

mail error

Post 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');
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

You don't have an SMTP server running on port 25?

Set the correct SMTP server in php.ini ;)
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

is it possible to set it in the script?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

ini_set("SMTP", "smtp.foo.tld");
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

You'll need to change "smtp.foo.tld" to whatever the address of your SMTP server is.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

In the outlook's internet account's value is mail.myserver.com
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Good. So what have you tried?
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post 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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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)
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

Thanx, i will try it.
Post Reply