-3

Here $msg and $subject are the variables getting values from the form. When the submit button is clicked, mail() function is to be called.

But there is a warning displayed:

Warning: mail(): Failed to connect to mailserver at "`" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\wamp\www\abhishek\wp-content\themes\abhishek\career.php on line 18.

Here is my code:

$msg=$_POST['msg'];
$subject=$_POST['subject'];
mail('email@example.com',$subject,$msg);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
user3717775
  • 45
  • 1
  • 7

2 Answers2

1

You would need to setup a mail server locally on your machine.The mail function needs SMTP servers for sending out the mails.So you would need to mention the smtp port and smtp host on the php.ini file.

.Please have a look at a similar question here

Community
  • 1
  • 1
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26
-2

This is just an example, change values......

$header = "From: contact@".$_SERVER["SERVER_NAME"]."\n";
$header .= "Content-Type: text/html; charset=utf-8\n";
$recipient = "abhijain.cse@gmail.com"
$subject = $_POST['subject'];

    $body='<table width="90%" border="0">
    <tr>
    <td><b>Name:</b></td> <td>'.$name.'</td>
    </tr>
    <tr>
    <td><b>Email:</b></td> <td>'.$email.'</td>
    </tr>
    <tr>
    <td><b>Message:</b></td> <td>'.$message.'</td>
    </tr>
    <tr></table>';

    $res=@mail($recipient,$subject,$body,$header);
Edwin Thomas
  • 1,186
  • 2
  • 18
  • 31
  • 2
    The user is getting a message saying `Failed to connect to mailserver`. The issue is a connection problem, and this answer doesn't deal with that at all. – andrewsi Oct 10 '14 at 12:24