Jump to content

Recommended Posts

Hi Guys,  :D

 

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 = "jonathangilmartin@yahoo.co.uk";
      $subject = "Subject!";
      $body = "whatever you want to email";
      $from = "From: Jon <john@beach.es>";
      $p5 = '-f john@beach.es';
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 !!  :D

 

Truegilly  :-*

 

Link to comment
https://forums.phpfreaks.com/topic/61597-mail-help-please/
Share on other sites

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.