truegilly Posted July 24, 2007 Share Posted July 24, 2007 Hi Guys, im trying to send out the most basic e-mail using PHP and the mail() function. the problem i have is that it will always return true but the message is never received and im not sure if its even sent. heres my code.... $email = "[email protected]"; $subject = "Subject!"; $body = "whatever you want to email"; $from = "From: Jon <[email protected]>"; $p5 = '-f [email protected]'; if(mail($to,$subj,$mesg,$from,$p5)){ echo " sent ok "; } else { echo " failed "; } I think the problem I have could be due to the server I am hosting the site on, but dont quote me on this as im not sure. The site is hosted on my university server, ive now graduated so I cannot ask the support team if any ports are blocked. Does anyone know a way of testing a servers ports, if this is even necessary of course ! can anyone explain the typical server requirements to send e-mail using PHP, i assume port 25 must be open and the server must accept SMTP. Forgive me for asking a dumb question but I take it that i cannot test the mail() function from my testing apache server installed on my local PC ? Also you will have noticed that i have a yahoo e-mail address, would i have to make any changes to my account to get this working ?? its only a standard free e-mail account. Any help is much appreciated !! Truegilly Link to comment https://forums.phpfreaks.com/topic/61597-mail-help-please/ Share on other sites More sharing options...
truegilly Posted July 24, 2007 Author Share Posted July 24, 2007 bump Link to comment https://forums.phpfreaks.com/topic/61597-mail-help-please/#findComment-306710 Share on other sites More sharing options...
stlewis Posted July 25, 2007 Share Posted July 25, 2007 Hey! Honestly, I don't have a lot of time to analyze what you've got here...but here's a test...I've attached a mail script that I know works 100% of the time, you've just got to "fill in the blanks" so to speak...give this a go on the server, if it works, then see if you can figure out what's different in your code...if it doesn't, then it's something on the server. Peace. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/61597-mail-help-please/#findComment-306791 Share on other sites More sharing options...
plutomed Posted July 25, 2007 Share Posted July 25, 2007 Where have you defined the variables $to, $subj, $mesg? Link to comment https://forums.phpfreaks.com/topic/61597-mail-help-please/#findComment-306805 Share on other sites More sharing options...
truegilly Posted July 30, 2007 Author Share Posted July 30, 2007 stlewis: - Thanks for the mailer im gonna try it right now !! plutomed: - sorry the php code was confusing, i was playing around so much that i copied some code where the variables were renamed !! Truegilly Link to comment https://forums.phpfreaks.com/topic/61597-mail-help-please/#findComment-311286 Share on other sites More sharing options...
truegilly Posted July 30, 2007 Author Share Posted July 30, 2007 Hi, thanks for that yes it did work but not from my uni server, it looks like they have blocked port 25. just out of interest does the mail() function pose a bit of a security risk as i seem to be able to send messages from other peoples e-mail address ?? thanks Truegilly Link to comment https://forums.phpfreaks.com/topic/61597-mail-help-please/#findComment-311349 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.