Emailing through PHP

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
wqr786
Forum Newbie
Posts: 13
Joined: Fri Sep 08, 2006 2:47 am

Emailing through PHP

Post by wqr786 »

I use

Code: Select all

mail($to,subject....)
but this code is not working on my server.

I try it like this:

Code: Select all

if(mail($variables.....))
{
 echo "mail sent";
}
else
 echo "not sent";
please provide me with code properly working. i think there's some smtp problem, but can't figure out. smtp is running on my local server. if you could make one single file which has code and sends email, please let me know.\
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

wqr786 wrote:please provide me with code properly working.
ask help, not code. put a php file with following contents on server

Code: Select all

<?php phinfo() ?>
and see it the SMTP settings given there are correct... the server/sendmail setting is correct or not.
User avatar
gkwhitworth
Forum Commoner
Posts: 85
Joined: Tue Sep 05, 2006 8:28 pm
Location: Wasilla, Alaska

Okay.....

Post by gkwhitworth »

Well here is some code that is working properly:

Code: Select all

mail("email@domain.com", "Feedback Form Results" , "name: $firstName", 
		"From: $firstName <$email>");
		header ("Location: http://www.gkwinspired.com/contact/web_feedback.php");
This works. I had tons of problems with my SMTP situation. I checked our server out and realized that we route our SMTP into our server, we actually don't have an SMTP server running. If you can find out the ip address of the SMTP server that you guys currently use you can use the following code:

Code: Select all

ini_set("SMTP","SMTP IP ADDRESS GOES HERE");
On the server there is a master php.ini file that controls the master SMTP settings, and if you control the server I would set it in there. But if you are just a user you can use this code and it will override the settings in the php.ini file.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I don't belive the SMTP address is settable in ini_set(). Use a mailer library if you need SMTP. Swift Mailer will work.
Post Reply