Jump to content

Recommended Posts

I am new to PHP, I have a website done in HTML and PHP.In my site,I have a form that sends mail. 
 

My PHP code is 

 

?php

 
try{
$to = 'test@test.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: noreply@test.com' . "\r\n" .
'Reply-To: test@test.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers))
{
echo("<p>Email successfully sent!</p>");
}
else{
echo("<p> Email delivery failed </p>");
}
}
catch(Exception $e){
echo 'Caught Exception', $e->getMessage(), "\n";
}
?>
 
I am using valid to and from addresses, but i always get the message "Email delivery Failed" and I dont get the email.
Also I have deployed my website in windows server, are there any configurations to be done on the server.
 
Thanks for your help in advance.
 

Hi,

 

@ DENNO020 : Feel honoured, he came here for help.

 

 

Divide and conquer...

 

Code looks fine, though I am tired and had a few to many drinks, lets assume all is ok, since no other errors came up... Give this a try:

  1. Check if your SMTP is setup (Reference: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true),
  2. Check Port 25 is open on the server,
  3. Check your php.ini is setup to these configurations: http://www.php.net/manual/en/mail.configuration.php.

Note: If you are using a home computer for the server, beware that some ISP's block port 25, alternative ports can be used default ports: 25 or 587 (reference: http://www.arclab.com/en/amlc/list-of-smtp-and-pop3-servers-mailserver-list.html)

 

See how you go, if none of above helps, please let us know, we are always happy to help.

I tried all the steps mentioned above but I still get the message "Email delivery Failed".
I saw the following error in PHP Log:

PHP Warning :  mail(): SMTP server response: 530 5.7.1 Client was not authenticated in on line 10.

Line 10 is if(mail($to, $subject, $message, $headers)) in my PHP file.

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.