You can use the PHP mail() function to send an email with PHP. The simplest way to do this is to send a text email. This is one way to handle sending you the results when a visitor to your website fills out a form.

## Basic PHP email() function code

Below is the code for the baic email function. We can take the script and actually use a form on our website to set the variables in the script above to send an email.

<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) { //Email information$admin_email = "someone@example.com";
$email =$_REQUEST['email'];
$subject =$_REQUEST['subject'];
$comment =$_REQUEST['comment'];

//send email
mail($admin_email, "$subject", $comment, "From:" .$email);

//Email response
echo "Thank you for contacting us!";
}

//if "email" variable is not filled out, display the form
else  {
?>

<form method="post">
Email: <input name="email" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="comment" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>

<?php
}
?>

So letâ€™s now review what the form is actually doing.

1. The first part checks to make sure the email input field is filled out. If it is not, then it will display the HTML form on the page. If the email is in fact, set (after the visitor fills out the form), it is ready to send.

2. When the submit button is pressed, after the form is filled out, the page reloads and reads that the email input is set, so it sends the email.

Keep in mind, this is a basic tutorial to explain how to use the mail() function in PHP. Using the method, exactly the way it is, can be insecure and should not be used on your website. This tutorial is aiming to provide you the basic of how to use phpmail() and for further use, you may want to look into securing your code to possible hacks.

To learn more about the PHP email function, please see the article on How to create a custom PHP contact form with more information on validation and error checking. If you need further assistance please feel free to ask a question on our support center.

### Social Media Login

Social Login Joomla

### Related Questions

Here are a few questions related to this article that our customers have asked:
Would you like to ask a question about this page? If so, click the button below!
 sankar guru n/a Points 2014-04-10 3:26 am Hi ,  This code is working properly and display ed the msg as Thank you for contacting us but mail is not send to the correspomding mail address.. pls give any suggestions...
 JacobIMH Staff 9,968 Points 2014-04-10 4:56 am Hello Sankar, It's possible that the message is ending up in a spam folder in the recipient's email address due to the mail coming directly from a PHP script. If that is the case, you could use something like phpMailer in order to send an SMTP authenticated email. Either that or there is some incorrect information typed in to your script. The Thank you for contacting us! message is displayed if the email form is submitted, but it doesn't actually check to ensure that the mail was delivered. If you have access to the server's mail logs, you should be able to see if the PHP mail attempt is making it to the local server to even attempt a delivery out. It looks like we might need to update the example script used in this guide to at least wrap the code with if (!mail( ...)){ echo "Failure" } code to see if the server accepts the PHP mail attempt. However this is more just a proof of concept then something you'd probably want to use on a live contact form for your website. - Jacob
 sankar guru n/a Points 2014-04-11 12:07 am Hi Jacob,   i was alredy used the phpmailer code it was shown the error of Message was not sent.Mailer error: SMTP connect() failed..
 JacobIMH Staff 9,968 Points 2014-04-11 12:20 am Hello Sankar, If you're getting a SMTP connect() failed error, then this means your PHP script can't establish a SMTP connection with the server you've entered into your script. Are you possibly trying to connect to a secure mail server by chance? You might need some additional settings in your phpMailer script such as: $mail->SMTPSecure = 'tls';$mail->Host = "secure.example.com"; If you're still having issues let us know. - Jacob
 Jones n/a Points 2015-04-10 7:23 pm please am facing the challenge in using php to send mail. this is my code $b){$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }$headers2 = "From: noreply@YourCompany.com";   $subject2 = "Thank you for contacting us";$autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.oursite.com";    if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a name, please go back and try again";}   else {     $send = mail('user@example.com',$subject, $message,$headers);     mail($to,$subject, $body,$headers);  $send2 = mail($from, $subject2,$autoreply, $headers2); if($send)   {header( "Location:localhost/thankyou.html" );}   else   {print "We encountered an error sending your mail, please notify webmaster@YourCompany.com"; }   } }  ?>
 John-Paul Staff 25,607 Points 2015-04-13 9:55 am Hello Jones, Thank you for your question. I recommend reading our guide on How to create a custom PHP contact form with validation, since it provides a successful example. If you have any further questions, feel free to post them below. Thank you, John-Paul
 Dhananjay Das n/a Points 2015-07-16 9:12 am Sir,      The mail is not sent with my mail() function coding that is"  ". What will be correct mail() function. Sir, Please advice me.
 John-Paul Staff 25,607 Points 2015-07-16 1:44 pm Hello Dhananjay, Thank you for contacting us. Have you tried following the above guide? We also provide a helpful example in our guide How to create a custom PHP contact form with validation. Thank you, John-Paul
 abstract n/a Points 2015-04-22 9:08 pm alter the line mail($admin_email, "$subject", $comment, "From:" .$email); to mail($email, "$subject", $comment, "From:" .$admin_email); it will work.
 vic n/a Points 2015-07-08 11:48 pm nice post
 smruti n/a Points 2015-09-02 8:33 am thanks for this help in this code can i use attachment code and mail my id ???
 Arn Staff 35,172 Points 2015-09-02 10:29 pm Hello Smruti, Thanks for the question, but can you provide more detail about what you're trying to do? We're not sure what you referring to as "attachment code" or by "mail my ID". Please give us a little more info and we would be happy to help if we can. Kindest regards, Arnel C.
 php n/a Points 2015-11-16 9:05 am This code work for me ... thanks bro
 abu n/a Points 2016-06-14 2:18 am thank u this code is working
 bhagyshri n/a Points 2014-04-25 2:13 am mail is not send to the correspomding mail address.. pls give any suggestions...and i m a new devoloper to php socan u sugest me how to use  phpMailer script...
 JeffMa Staff 11,186 Points 2014-04-25 7:52 am for information on using phpMailer, I recommend that you review our article on using phpMailer to send mail using PHP.
 darshan n/a Points 2014-07-02 3:30 am how to work SMTP i Dont no can anyone explais pls.... advance thank
 scott Staff 40,028 Points 2014-07-02 7:38 am Hello Darshan, SMTP settings are explained here. If you need to send an SMTP authenticated message you may want to check out the phpmailer article. Kindest Regards, Scott M
 Nathan n/a Points 2014-05-13 9:23 pm Just wanted to mention an issue I just ran across in the hopes that it might help someone else.  In our situation we use inmotion for web hosting, but host email for the same domain locally in our network. When the domain was set up on inmotion, thedefault setting was to use InMotion's MX server, so all email sent to address on our domain were attempted delivery to inmotion rather than our mail server.  I think I've fixed this by setting the mx servers to be remote instead of local.
 JacobIMH Staff 9,968 Points 2014-05-14 5:44 pm Hello Nathan, and thanks for the comment! Yes you are correct that if your domain's email is not hosted with us, when you try to deliver from a PHP script it will try to deliver it locally unless you change DNS records to have email hosted by a 3rd party. You also need to set the Email Routing option to Remote Mail Exchanger instead of the local one like you mentioned. Thanks again for your comment! - Jacob
 snehal n/a Points 2015-08-28 2:53 am hiii sir please give me a mail code with calling database.. please fast reply please.... sir.....
 TJEdens Staff 10,077 Points 2015-08-28 11:21 am Hello Snehal, While we do not help provide custom solutions such as that you may find the following article helpful to go along with the PHP code in this article. Best Regards, TJ Edens
 Olorunnisola abiodun n/a Points 2014-06-27 5:28 am Please, i am sending email via phpmail() with a link, the link work perfectly but did not display any information posted to the link from sql. And even the email is not  entering into inbox of my client. can you help me?
 scott Staff 40,028 Points 2014-06-27 9:09 am Hello Olorunnisola, If you are not getting any errors or messages saying the email was not sent, but the recipient is not able to see the email, you will want to contact our Live Support team to see if they can confirm the email actually left the server. If it did, then the script worked properly and the issue maybe on the receiving end. If not, they may be able to see something specific to advise you on a next step. Kindest Regards, Scott M
 Olorunnisola abiodun n/a Points 2014-06-27 5:33 am Please someone teach me how to create ds text formats and attached files form computer to a textarea on a webpage.
 scott Staff 40,028 Points 2014-06-27 9:12 am Hello Olorunnisola, We are unfamiliar with what you mean by ds text format. Could you be more specific in what you are trying to accomplish? Kindest Regards, Scott M
 Olorunnisola abiodun n/a Points 2014-06-27 10:27 am Thank you scott,  here are my codes:     //var_dump($link); //$msg = wordwrap($msg,70);$subject = "Call For Meeting";    $message = "Dear"." "."Sir\Madam,". "You had been invited to attend a meeting by the name organization"." ".$org_ind." "."that is to hold on"." ".$date." "."by"." ".$start_time." "."via online, Based on"." ".$meeting_title."."."Your feedback about this proposed meeting will be of better help for the preparation. Please click to give your view."." "."Notification"." "."Thank you. "; // Always set content-type when sending HTML email$headers = 'MIME-Version: 1.0'. "\r\n"; $headers .= 'Content-type:text/html;charset=UTF-8'. "\r\n";$headers .= 'From: Gentlesoul '. "\r\n";    foreach($_POST['division_name'] as$key =>$email) {$mail = mail($email,$subject,$message,$headers);       //var_dump($email); if ($mail) {       echo "

Message sent!

";      } else {        echo "

Message delivery failed...

";      }   } The project is my own personal project that i want to host by tuesday, please help me. have not being here before, this will be my first time. About the text format! I mean to give client opportunity to bold,italic or number list to typing text has he or she type.        echo "

Meeting set successful!

"; }
 Olorunnisola abiodun n/a Points 2014-06-27 10:33 am on my own system here, if i view my mail send has a text, i saw everything. But on other peoples laptop, they saw the message and the link but inside the link all the field i call from mysql server to that notification page was not showing.
 John-Paul Staff 25,607 Points 2014-06-27 12:00 pm Hello Olorunnisola, Thank you for contacting us today. Since you are having trouble coding a PHP contact form, I recommend following our updated guide on How to create a custom PHP contact form with validation. That tutorial provides a successful example that should help you code your form. If you have any further questions, feel free to post them below. Thank you, -John-Paul
 clinton n/a Points 2016-03-24 11:55 am for the email  to be  sent do you need to have  hosted  the  site ? or it can  just  work  locally  using wamp when there is internet
 Fawn n/a Points 2014-06-30 4:35 pm I am using Wordpress WooCommerce and my order confirmation emails are not being sent. I am using an email forward to send mail (example@mydomain.com forwards to an AOL email account). Would this prevent emails from being sent if I am using the default DNS records? I also have not changed the Email Routing option to Remote Mail Exchanger.
 JacobIMH Staff 9,968 Points 2014-06-30 5:36 pm Hello Fawn, I would recommend sending your order confirmations directly to an email account hosted on the same domain as your WordPress site to rule out any 3rd party delivery errors. If you are missing any order confirmations at your AOL.com address I would suggest that you login to webmail and check for them locally on the server. I do see some delivery errors from your account to AOL.com and this will happen from time to time, as AOL offers free email accounts and sometimes will reject automated messages from servers, especially on their first delivery attempts. This is also referred to as temporary defferment and is mentioned on this AOL page about 421 errors which is what some of your mails are getting rejected by. Please let us know if you had any further questions. - Jacob
 Morphy n/a Points 2014-07-06 2:37 pm i'm new in programming, i created a form to send email from my website to yahoomail but i got this error Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() what can i do
 JacobIMH Staff 9,968 Points 2014-07-06 6:42 pm Hello Morphy, As your PHP error states, it can't connect to the server localhost on port 25. You'll need to check with your web host to find out what mail server you should be using. You might need to send mail with phpMailer instead of the default PHP mail() function depending on your server configuration. You more than likely need to define some SMTP settings, and use the same server and account information you would use when setting up a normal email account on your desktop. Or your web host might let you know you need to define another SMTP port rather than 25 in your php.ini file. - Jacob
 kumar Randhir n/a Points 2015-01-06 7:49 am how to send emaim using form form indlude all field which is send me
 Eihto n/a Points 2014-07-06 11:41 pm hi, i want to create auto responder and get the data into database and its like send a data differently to sender. help me how could i create it. im very new in php
 scott Staff 40,028 Points 2014-07-07 7:12 am Hello Eihton, While not a difficult task, it would require a few more pieces to be added. To auto respond to the customer, you would need to add another piece of code that emails out that the information was received. Then, to add the data to the database you would need to have the proper tables set up in an existing database, code for php to connect to the database, then build your SQL query using the information input by the user as the data to insert. Finally you would insert that data into the database. Unfortunately we currently do not have that type of tutorial information available, however there are many articles and tutorials around the web for each part that is required. I have given you the layout, so go from there and see if you can find code samples to assist. Be sure to also read up on error checking and avoiding SQL injection from malicious users to protect your database. We do have an article that may help you get started. Kindest Regards, Scott M
 antara n/a Points 2014-07-09 11:17 am Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\design\mail.php on line 13 what will i do now
 scott Staff 40,028 Points 2014-07-09 11:36 am Hello Antara, When you use 'localhost' in your settings, that means it will look on the current computer. If you are using this on your local computer, yuo likely do not have it set up as a mail server, which is why you are getting the message. You will need to have it point to a server with mail serving functionality, such as your webhosting server. Kindest Regards, Scott M
 Pooja n/a Points 2014-08-21 1:02 am Q .As u ve mentioned here $admin_email = "someone@example.com";to send mail to that particular mail address.. I m using phpmailer n its working fine for me to send mail to any gmail or yahoo mail but not to any custom mail address.  I want to send mail to any custom domain address by phpmailer. Any help here ??  scott Staff 40,028 Points 2014-08-21 7:39 am Hello Pooja, If the you are successfully sending emails to some addresses but not others, then the issue would not likely be with the function. You will want to test by sending an email from your server via webmail to the address that is not receiving it. Look for a return message in that email account for the reason why it is not getting through. Kindest Regards, Scott M  priya solanki n/a Points 2014-08-26 5:50 am should give the explanatory example like on w3 schools (try yourself).  John-Paul Staff 25,607 Points 2014-10-06 10:28 am Hello priya, Thank you for your suggestion. For anyone else who may find this post, here is a helpful link to the w3Schools page on PHP 5 mail() Function. Thank you, John-Paul  mo n/a Points 2014-09-05 6:34 pm Hi there, i have made use of the basic PHP mail code thanks to you but the issue im having is that the email comes through to me from my hosting server and no comments added to the email... subject is the visitors email address as i set it... see below and please advise if i am doing it wrong:  Arn Staff 35,172 Points 2014-09-05 6:50 pm Hello Mo, Make sure that you when you use the code above, that it's spaced out with the comments on their own line - like the following:  //if "email" variable is filled out, send email if (isset($_REQUEST['email'])) { //Email information $to = "admin@mydomain.co.za";$name = $_REQUEST['name'];$email = $_REQUEST['email'];$telephone = $_REQUEST['telephone'];$comments = $_REQUEST['comments']; //send email mail($to,$name,$comments); //Email response echo "Thank you for contacting us!"; } ?>  Your email form requires should be asking for the comment as well. As per the code above, the form section has "comment" set in the text area. I hope that helps to clarify the issue! Please let us know if you have any further questions. Regards, Arnel C.
 mo n/a Points 2014-09-05 8:36 pm Hi, Thank you for the speedy reply. I have made changes to the PHP code and now have the message come through in the body of the mail but still cannot get the visitors email to come up as FROM:.... just comes from my webhost name. see code below:
 Arn Staff 35,172 Points 2014-09-05 8:54 pm Hello Mo, If you look closely at your code, take a close at your $from. I think that's the problem. Make sure you're using the right variable there and then everything should be okay. I hope that helps! Regards, Arnel C.  chike n/a Points 2014-10-02 5:57 am pls i am new in web designing and development. how can i design a php webpage that i can use to send and recieve mail like that of yahoo and gmail. it will have all the features like the trash box, draft box, inbox, sent and delet links. if you can send m the codes and syntax it will be welcome. pls forward to my email  scott Staff 40,028 Points 2014-10-02 1:27 pm Hello Chike, While your question is about email, it does not relate to this article directly. I have moved your question to be a brand new question. You can find it here. Kindest Regards, Scott M  Satbir Singh n/a Points 2014-10-13 5:00 am following code is not working -----------------------------------------------------  scott Staff 40,028 Points 2014-10-13 10:43 am Hello Satbir, Are you getting an error message? If so, what is it? Where are you trying to use this code? Is it a webserver or a WAMP, XAMP, LAMP setup? Kindest Regards, Scott M  Hi all n/a Points 2014-10-24 1:37 pm I use LAMP postfix centos and this script :)) i recive Thank you for contacting us! but i dont recive the mail please help me  scott Staff 40,028 Points 2014-10-24 2:56 pm Hello, You will need to check in your email logs to see if the email went out or if there is an error message. Kindest Regards, Scott M  Kaleb n/a Points 2014-10-28 9:48 pm this code is selecting an email address from my database and is going to send a message to the selected email. the code works fine but not the mail function for$to = $address$to = $address; (mail($to,$subject,$txt,$headers); // select statement$SQLString = "SELECT email\n"        . "FROM tutor\n"        . "WHERE MATCH(text_data) AGAINST ('{$messageText}' IN BOOLEAN MODE)\n" . "GROUP BY id\n" . "ORDER BY sum(5) DESC"; echo$SQLString;          $result = mysql_query($SQLString);        // Verify it worked        if (!$result) echo mysql_error(); // execute select statement$row = mysql_fetch_row($result); // Should show you an integer result.$address = print_r($row, true); echo$address;                $to =$address;        $subject = "testing...";$txt = $messageText;$headers = $senderPhone; if (mail($to,$subject,$txt,$headers)) { echo "successful"; } else { echo "error"; } thanks for any help in advance :)  scott Staff 40,028 Points 2014-10-29 9:07 am Hello Kaleb, From the way you phrased your question, it seems that you are having issues with$to taking the value of $address. The code snippet you provided does not show where the$address variable is filled. What do you get when you echo $address? The$to = $address is not a function, but an assignment, making$to the value of whatever is in $address at the time. Do the other variables ($subject, $txt, etc) receive their values? The mail($to,$subject,$txt,$headers) function is called but you do not have any code to catch and display the return code to know why it is failing. You will need to do that in order to understand what is going on. Kindest Regards, Scott M  makhan singh n/a Points 2015-11-24 3:10 am · Move an account to “Email Error” if a number of email notifications fail to reach the recipient. The portal should keep a count of the number of times a consecutive email error occurs – once the number reach a certain limit then the account should be moved.  alaa n/a Points 2014-11-11 5:36 am Hello Iam Alaa i have error and i can not find it can help me when i sent to email see this massage what can i do Deprecated: Function eregi() is deprecated in C:\wamp\www\Light\js\sendmail.php on line 49  JeffMa Staff 11,186 Points 2014-11-11 10:40 am This means that you are using a function that has been removed from newer versions of PHP within that code located at C:\wamp\www\Light\js\sendmail.php. You will need to further investigate the code of that file and re-write the PHP to allow it to work on newer versions of PHP.  kiran n/a Points 2014-12-05 7:25 am when use this code this error ocur(" Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()") and we can not handle this :O  TJEdens Staff 10,077 Points 2014-12-05 11:13 am Hello Kiran, Unfortunately PHP's mail() function does not support SMTP protocols. I did however find an alternative on a Stack Overflow thread. Kindest Regards, TJ Edens  Nayeem Sarkar n/a Points 2014-12-07 8:40 am I am use your phpmail function ok, function is work fine & mail send & receive ok, when i am add my more input box main name input box then create a problem. Name: Company: Email: Subject: Message: Problem::Warning: mail() expects at most 5 parameters, 6 given in /home/mailsend.php on line 22 how to solve it.  scott Staff 40,028 Points 2014-12-08 3:39 pm Hello Nayeem, The php mail() function needs at least 3 arguments, and has two optional ones, totaling 3-5 arguments. These arguments are specific arguments and not ones you can create on your own. The required arguments are 'to', 'subject', and 'message' with the optional ones being 'additional headers' and 'additional parameters'. Your call to the function has some different arguments and totals 6, so you will need to fit those custom arguments into your message and then reformat the function call to match the standard php mail() function call. You can learn more about that function here at thephp manual page. Kindest Regards, Scott M  Arvinder n/a Points 2014-12-16 3:42 am Hi, I have the same problem. I am using the PHPmail script. I config this script and it shows the message "Mail has been sent". But didnt reached at desired email location. Please Anyone helps me to solve this issue.  scott Staff 40,028 Points 2014-12-16 9:16 am Hello Arvinder, If you are working with the phpmail function and got the "Mail has been sent" message, it should have been sent from the server. You will now need to check the server logs and see if the message was indeed sent and if it was received properly by the other server. Kindest Regards, Scott M  Anant n/a Points 2015-01-08 10:20 am Thanks for so nice form. I wanted to know that how to send email for CC and BCC alingwith main admin email.  scott Staff 40,028 Points 2015-01-12 3:35 pm Hello Anant, To add CC and BCC you need to include those as part of your headers. Replace the 'From' section with a$headers variable. Prior to calling that, you need to add the header content. It will look like something below: $headers = "From: no-reply@example.com\r\n" . "X-Mailer: php\r\n";$headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";$headers .= "CC: admin@example.com\r\n"; $headers .= "Bcc: admin@example.com\r\n"; This should assist you. Note that this is a sample and has not been tested, further modification may be required. Kindest Regards, Scott M  Anant n/a Points 2015-01-14 7:35 am Thanks for your kindly reply. Next, you are requested to provide the complete code at one place with facility of CC and BCC email and CAPTCHA protection. Thanks and regards, Anant  scott Staff 40,028 Points 2015-01-15 11:13 am Hello Anant, While we are happy to provide assistance, we do not provide coded solutions upon request. With the article above plus the information provided in the support center, you should be able to put together a form in the format you desire. Kindest Regards, Scott M  Atul Adhikari n/a Points 2016-01-20 1:27 am Hi Scott, Your header for Bcc is not working, it should be like this $headers .= "BCC: admin@example.com\r\n";but apart from that,its working fine! Thanks.
 Harshak Ratn n/a Points 2015-01-15 3:52 am   Dear sir,               i am working on this code and it is not working . i want send the information filled by the user to our mail but this code doing nothing please suggesed me .
 scott Staff 40,028 Points 2015-01-15 10:44 am Hello Harshak, Unfortunately this snippet of code will not be helpful in fully troubleshooting the issue. What troubleshooting steps have you tried? Are you getting an error message? Are you able to echo out your specific variables to ensure they are being filled? Kindest Regards, Scott M
 kevin n/a Points 2015-01-21 4:18 am can i fill $admin_email = "someone@example.com"; with$admin_email = "someone@example.com, someone2@example.com "; ?
 Arn Staff 35,172 Points 2015-01-21 11:23 am Hello Kevin, Thanks for the question. There is not anything saying that you can't have two admins, so you're welcome to try it. If you want to be sure that the email makes it to BOTH email admins, then set up a forwarder for the administrator email address so that it forwards to your second administrator email address. Regards, Arnel C.
 Crystal n/a Points 2015-02-05 5:45 pm Thank you!!
 Arun Babu B N n/a Points 2015-02-06 5:55 am PHP must be configured correctly in the php.ini file with the details of how your system sends email. Open php.ini file available in /etc/ directory and find the section headed [mail function]. Windows users should ensure that two directives are supplied. The first is called SMTP that defines your email server address. The second is called sendmail_from which defines your own email address. The configuration for Windows should look something like this: [mail function] ; For Win32 only. SMTP = smtp.secureserver.net ; For win32 only sendmail_from = xyz@yourdomain.com  Linux users simply need to let PHP know the location of their sendmail application. The path and any desired switches should be specified to the sendmail_path directive. The configuration for Linux should look something like this: [mail function] ; For Win32 only. SMTP = ; For win32 only sendmail_from = ; For Unix only sendmail_path = /usr/sbin/sendmail -t -i    make the required modification in the php.ini file and try once again.
 Romeo n/a Points 2015-02-19 9:32 am I have a problem about my mail function, Its working on all other domains but not working on our domain. we have a .ae domain that is working(I can recieve emails from them) but the .com is not (we are using Gmail as our hosting provider).   Thanks in advance
 John-Paul Staff 25,607 Points 2015-02-19 3:34 pm Hello Romeo, Thank you for your question. We are happy to help, but will need some additional information. What happens when you try to send the emails? Are you getting any errors? What are they? What is the .com domain? Have you confirmed the MX records are pointed to Gmail correctly? Have you made any DNS changes to the .com domain in the last 24 hours? Thank you, John-Paul
 Romeo n/a Points 2015-02-22 12:49 am I dont reveieve any error messages, Email is working on other domains. I have a domain of romeo@travelats.com and romeo@travelats.ae, I was able to get the email using the travelats.ae but not the .com. And I have not made any changes on the DNS server. here is my code   $order=$_POST["order"]; $amount=$_POST["amount"]; $bank=$_POST["bank"]; $mail=$_POST["email"]; $sender = "ATS Travel "; // multiple recipients$to  = $mail; // subject$subject = 'Payment Receipt';   // message     $body = << Your transaction is succesful! Order:$order
Amount: $amount Bank Reference Number:$bank
EOD; $headers .= "From:$sender\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $success = mail($to, $subject,$body, $headers);$theResults = <<
 scott Staff 40,028 Points 2015-02-23 5:00 pm Hello Romeo, You will want to place code around the mail function to test any error codes that it may be throwing. Kindest Regards, Scott M
 mav n/a Points 2015-02-23 3:00 am my not receiving any mail,can you please let me know thw mistake

 scott Staff 40,028 Points 2015-02-23 5:02 pm Hello Mav, Have you gotten any error messages? Have you tried echoing out the variables to be sure they are all correct? Have you tried any error trapping on the mail function to see if it is throwing any other error types? Kindest Regards, Scott M
 Guy n/a Points 2015-03-07 9:10 pm Hi. This code doesn't work for me either. Would be great if there was something like this that addressed my and other people's issues. Some clear instructions for newbies would be much appreciated. Back to googling for simple form guidance...
 scott Staff 40,028 Points 2015-03-10 7:49 am Hello Guy, Are you getting any particular error messages? If so, paste them here and we will be glad to take a look for you. Kindest Regards, Scott M
 Ramesh n/a Points 2015-03-16 6:02 am i want to send the copy of mail to users mail id how can i do this
 John-Paul Staff 25,607 Points 2015-03-16 9:49 am Hello Ramesh, Thank you for your question. The above guide allows users to send a text email to you from a form. There are many ways for you to send an email to users, but I recommend reading our guide How to send a message to your phpList mailing list. Thank you, John-Paul
 purva n/a Points 2015-03-18 2:29 am hi, what the conclusion of above disscussion..............?????? plz tell me exact solution that what changes should i make in php.ini and sendmail.ini file to sending rhe mail to user(that he should recive the mail). The output is only the messge.how should i know that mail is deliverd to the user??? i dont want to use phpmailer() function. thanks
 Arn Staff 35,172 Points 2015-03-18 10:55 am Hello Purva, Apologies, but I'm not sure what you're asking. The comments in this section are FOR using the php mail function. If you don't want to use it, then you need to be using something else and your comment should be in an article appropriate to your topic. Changes in the php.ini and sendmail.ini files will NOT send email to a user. You will need to have some code that will do that. There built-in functions (such as phpmail and mail) in PHP that can be coded for that purpose, but we do not provide code beyond what we have provided in the articles written within the Support Center. If you want a tutorial on how to use phpmail, please see phpmail function. Kindest regards, Arnel C.
 vandana n/a Points 2015-03-19 8:53 am hello sir,   How to give HTML lINK in mail function of php.
 John-Paul Staff 25,607 Points 2015-03-20 3:47 pm Hello vandana, Thank you for your question. I found a post via online search, where they are discussing possible ways to embed a link in php mail function. This may be a good starting point in determining how to code this. Thank you, John-Paul
 Muhammad Himayata n/a Points 2015-04-09 1:43 am Hello! please help me i want to send mail to group, thats i maintain in database(email addresses)
 scott Staff 40,028 Points 2015-04-09 9:18 am Hello Muhammad, You can either add more email addresses to the To section or create a forwarder on the receiving email that sends to the other desired email addresses. Kindest Regards, Scott M
 Muhammad Himayat n/a Points 2015-04-18 12:10 am Sir Scott....Hmmm, thats fine Sir......one thing more....Can I add multiple headers more than we use in routine? How?
 scott Staff 40,028 Points 2015-04-20 8:17 am Hello Muhammad, You could simply add a variable named headers and then add as many as you need. For instance: $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" You then insert that variable as one of the parameters in the mail() function. Kindest Regards, Scott M  Mohammad n/a Points 2015-04-24 9:54 am I wanted my email to be send as HTML format and this is the code. The recieved email is a text with html tags. // if no errors send email if(!isset($error_message)) { // Header $headers = "From: " . strip_tags($_POST['email_address']) . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['email_address']) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n";$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";   // Email $email_msg = '';$email_msg  .= "" . ""; $email_msg .= " Email was sent from: " .$URL . "

"; . . . $email_msg .= "";$mailTo = $mailTo; //send email mail($mailTo, $subject,$email_msg, "From:" . $email_address); if i added$headers to my mail line it will not work  mail($mailTo,$subject, $email_msg,$headers);   Please advice Thanks
 Arn Staff 35,172 Points 2015-04-24 4:02 pm Hello Mohammad, Unfortunately, we can't really provide coding support. However, we do try to point you in the right direction. Check out this Sending Nice HTML email with PHP. This post provides information that you could use to send email as HTML using the PHP mail function. I hope this helps to answer your question, please let us know if you require any further assistance. Regards, Arnel C.
 girish n/a Points 2015-04-28 5:11 am what are the necessary settings to be made while sending e-mail using mail() or phpmailer in php?
 scott Staff 40,028 Points 2015-04-28 10:07 am Hello girish, With phpmailer you will want to ensure you are using the proper SMTP settings. Kindest Regards, Scott M
 Karen n/a Points 2015-05-11 10:43 am HI, I am new to coding and would like some advice on the easiet and simplest way to set up a contact form page. I was thinking of using a webtemplate and my gmail to recieve the contact info. The webplate does not include any php help. I use microsoft webexpression for editing. Can you recommend a simple article to follow in a step by step. The more I read the more complex this is looking. Thank You in Advance for any guidance you can give me!
 TJEdens Staff 10,077 Points 2015-05-11 2:25 pm Hello Karen, You would just need to go to page -> Code and you would insert the code from this page. You would need to change the admin email address to your gmail.com account so the form knows where to send the emails to. Best Regards, TJ Edens
 Karen n/a Points 2015-05-12 10:57 am HI, Thank You for your quick response. I tried the code at the top of this page and it appears to work but no email shows up at my gmail email. Here is the link to my page http://ecbiz172.inmotionhosting.com/~efabri6/contact2.php   I copied and pasted the code and inserted my email, any ideas what I might need to change.
Email:
Subject:
Message:

 Arn Staff 35,172 Points 2015-05-13 2:53 pm Hello Karen, Based on your account I was able to take a quick look at your email logs and I could see that the email was working. I then briefly tested the code myself with my own email address and it also worked. I had it send to my Gmail account and I received messages. You might be forwarding your messages somewhere else, or there's a filter that's removing messages - you will need to check to make sure that a spam filter or something else is not in the way. I hope this helps to let you know that the function is working. If you have any further questions or comments, please let us know. Regards, Arnel C.
 Vijay Bhat n/a Points 2015-05-20 4:41 am Dear Friends, i want to send mail from php. but each time i run it in browser it displays error message Message could not be sent.Mailer Error: Extension missing: openssl i am posting my code below isSMTP();                                      // Set mailer to use SMTP$mail->Host = 'smtp.gmail.com'; // Specify main and backup server$mail->SMTPAuth = true;                               // Enable SMTP authentication$mail->Username = 'anything@gmail.com'; // SMTP username$mail->Password = '*************';               // SMTP password$mail->SMTPSecure = 'ssl'; // Enable encryption, 'ssl' also accepted$mail->Port = 995;                                    //Set the SMTP port number - 587 for authenticated TLS$mail->setFrom('THIS IS TESTING MESSAGE'); //Set who the message is to be sent from$mail->addReplyTo('anything@yahoo.com');  //Set an alternative reply-to address$mail->addAddress('anything@yahoo.com'); // Add a recipient$mail->addAddress('anything@yahoo.com');               // Name is optional$mail->addCC('anything@yahoo.com');$mail->addBCC('anything@yahoo.com');$mail->WordWrap = 50; // Set word wrap to 50 characters//$mail->addAttachment('/usr/labnol/file.doc');         // Add attachments//$mail->addAttachment('/images/image.jpg', 'new.jpg'); // Optional name$mail->isHTML(true);                                  // Set email format to HTML $mail->Subject = 'Here is the subject';$mail->Body    = 'This is the HTML message body in bold!';$mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; //Read an HTML message body from an external file, convert referenced images to embedded,//convert HTML into a basic plain-text alternative body//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' .$mail->ErrorInfo;   exit;} echo 'Message has been sent';  if some one had solution about this, plez contact me on my email id,....vijaybhat1981@gmail.com
 Arn Staff 35,172 Points 2015-05-21 10:14 am Hello Vijay, If you're missing the OpenSSL extension, it typically has something to do with the PHP.INI file. If you are an InMotion Hosting customer, then there should be a PHP.INI file local to your installation. Check out this post in concerning the issue. Regards, Arnel C.
 boukeri tayssir n/a Points 2015-05-20 3:08 pm  Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\icone-cnam\Contact.php on line 51
 Arn Staff 35,172 Points 2015-05-21 10:22 am Hello Boukeri, You should first try changing the port. Port 25 is typically blocked by many ISP's. Try using 587. If you continue to have a problem with it, then please see your documentation for WAMP. We do not provide support for WAMP issues as they are non-service related. If you were running the code on our server, then the WAMP code should not be referenced in the error message. I hope this helps to answer your question, please let us know if you require any further assistance. Regards, Arnel C.
 simhaa n/a Points 2015-05-22 3:54 am hai,i am getting this error Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\wamp\www\s\oc.php on line 13 can't get conformation mail
 John-Paul Staff 25,607 Points 2015-05-26 3:45 pm Hello simhaa, Thank you for contacting us. We are happy to help, but will need some additional information. Have you checked that port 25 is open on your server? The error suggests this may be the problem. Thank you John-Paul
 simhaa n/a Points 2015-05-27 12:35 am port 25 is open i have checked it  and changed it to 465and tryed it but cam to be same erroe port 465 and smtp()  and how vll we know whether port is open or not
 Arn Staff 35,172 Points 2015-05-28 2:34 pm Hello Simhaa, We're not sure where you're trying to run your code, but check out this post. You may require some server setup that is missing. This article will show you how to check on an port. I hope that helps to answer your question! If you require further assistance, please let us know! Regards, Arnel C.
 Sunny n/a Points 2015-06-05 4:04 pm Can the PHP mail() function work in localhost environment. Will the Email be sent.
 scott Staff 40,028 Points 2015-06-05 5:28 pm Hello Sunny, Unless you have set up your local environment to act as a mail server, it will not do so. You will need to test from a hosting server that can actually send the emails. You may also want to use an emulator such as the one linked below. We have not tested this program nor do we endorse it. http://www.toolheap.com/test-mail-server-tool/ Kindest Regards, Scott M
 Elizabeth Logan n/a Points 2015-06-15 7:52 am Hi, I have a question that I cannot seem to find an answer for online. Probably because it contains words that give me other info. I have a website that will allow users to sign up to. When they create their new member information, once all validation is done and all is correct it sends them an email with a validation link. They click on the link which then redirects back to the website. This allows for their info to be written in a temp table and once validated written to the actual table and the info from temp table deleted. All works fine except that I have to use the URL they click on to send the validation key back to the website which means acquiring the data via GET rather than POST... I am trying to find out if there is a way to send it via POST so that it is not accessible to eyes through the URL. Any direction to where to look how to do this would be great.... trying to search for information because of the words email, validation, post etc are bringing up everything but what I really want.
 scott Staff 40,028 Points 2015-06-15 3:17 pm You should be able to set a variable with either GET or POST so you can process it. Here is a thread on a popular forum that explains different ways to send variables to a waiting page. That should help you with your situation.
 Elizabeth Logan n/a Points 2015-06-15 8:32 pm Hi, Thank you. What I am looking for is to send a confirmation code back from someone's email to a webpage using POST rather than GET. I could code a form to be sent within the email and when they click validate it is a form submit so able to use the POST but I want to avoid using a form.I have no idea of any other way to send it from their computer back to the site as POST so the confirm code is not attached to the URL.  I have my form on the website which collects the user data, I process it with heavy validation and then they are sent an email with a link... I was using a link with the confirm code appended to it and then a GET in the webpage to validate but I have read in several places that is not a good idea yet I cannot seem to find how to get the user from their email back to the webpage without using GET. I am aware of using POST/GET in a webpage form, what I need is to use POST so that the data coming back from the validation email to validate that the person actually joined the website is not visable within the URL. Thanks again.
 suma n/a Points 2015-06-24 9:36 pm i create website and i want to send messages to my contact to their phone i'm  as admin,i need information about that
 John-Paul Staff 25,607 Points 2015-06-25 11:16 am Hello suma, Thank you for contacting us. It is possible to code/develop this in PHP, here is a link to a post where they discuss possible solutions. If you are using a CMS such as WordPress, Joomla, or Drupal, they may plugins, or addons for accomplishing this as well. Thank you, John-Paul
 Jmkapondo n/a Points 2015-07-09 9:35 am How to set in html form?
 John-Paul Staff 25,607 Points 2015-07-09 3:52 pm Hello , Thank you for your question. I found a guide online online titled "How do I add PHP code/file to HTML(.html) files" where provide an .htaccess rule that makes this possible. Thank you, John-Paul
 anton paraggua n/a Points 2015-08-02 9:58 am can you please help me i tried the code at the top of these page and it run but no email show up in my yahoo and gmail emails.. heres the code that i tried

This Websites Contains
Unknown Quantity
Please Type your E-Mail
Email:
Subject:
Message:

can you please help me
 scott Staff 40,028 Points 2015-08-03 12:46 pm You may want to contact Live Support and see if they can identify the email as leaving the server. Then you will be able to work from there.
 anton paraggua n/a Points 2015-08-07 6:33 pm do the code on top of this page can send email in local host?? i'm using xampp please the code runs smoothly but there's no email shows up in my emails..
 John-Paul Staff 25,607 Points 2015-08-10 9:25 am Hello anton, Thank you for contacting us. I recommend checking your mail logs for any record of transmission. This will help determine if it is failing in the code, or it is being delivered, and the server is rejecting it, etc. Thank you, John-Paul
 bhoomi n/a Points 2015-08-07 1:23 am hello,   i want a php script which sends email on customer's birthday without submiting code.simply means automatic mail sending.
 John-Paul Staff 25,607 Points 2015-08-07 1:02 pm Hello bhoomi, Thank you for contacting us. We do not have any guides on how to make a script that sends birthday emails, but i found several suggestions via Google search. Here are some examples: birthday script with mail functions to customer, and Send mail to different customer on their birthday . These offer some possible solutions. Thank you, John-Paul
 mahdi n/a Points 2015-08-08 11:32 am hi . sorry am not good in english ( i have a page php . in the page ther is 3 one for the e-mail and two for the username and the password . i want when some one write his e-mais . the page send his e-mail to my email . how can i do this please ?
 John-Paul Staff 25,607 Points 2015-08-10 9:53 am Hello mahdi, Thank you for contacting us. The above guide explains how to get the form to email information. For a more detailed information, see our guide on How to create a custom PHP contact form with validation. It provides a more complete tutorial, but you will have to customize the code to fit your need. Thank you, John-Paul
 smruti n/a Points 2015-09-03 2:30 am

In this code what is my error please solve it
 John-Paul Staff 25,607 Points 2015-09-03 9:38 am Hello smruti, Thank you for contacting us. What happens when you try to run this code? Are you getting an error? Did you follow the tutorial above? Thank you, John-Paul
 JeofDC n/a Points 2016-07-28 11:57 pm I tried this code, it prompted success but when i checked my email, there was none.
 Arn Staff 35,172 Points 2016-07-29 9:51 am Hello JeoofDC, Sorry for the problem with the email not appearing. We would need more information on the account and your settings if you need further assistance. Also, remember that any email may have been affected by Spam filters or rules if you have any. If you have any further questions or comments, please let us know. Regards, Arnel C.
 moses n/a Points 2015-09-03 11:56 am Thank you.   The code works but  i am getting the ""thank you for contacting Us" nessage on same page after clicking on submit. I want it to open on another page.   Please help in this regard,   Thanks
 TJEdens Staff 10,077 Points 2015-09-04 4:19 pm Hello Moses, You would need to put the action in the form such as *form action="send.php"* and then on the send.php it would execute the mail script and say your thanks. Best Regards, TJ Edens
 iAdmin n/a Points 2015-09-11 5:39 am Can you help me with this code? Please tell me where am i going wrong.
'.$check_msg.' Name:'.$name.'
Email:'.$email.' Comments:'.$comments.'

Thanks

';         $headers = "MIME-Version: 1.0" . "\r\n";$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";         $headers .= 'From: <'.$email.'>' . "\r\n";                           $from =$email;         $to = ; if(mail("admin@nfotech.com", " Contact Form : ",$comments, "From: $email")) { echo ''; } else { echo ''; } }?>  scott Staff 40,028 Points 2015-09-14 12:35 pm Hello iadmin, This is incomplete as I cannot see anything that has to do with the Thank You. I would need a complete cloned environment to troubleshoot which is something we just are not able to do. We are happy to answer any questions about any errors you get however. Kindest Regards, Scott M  balaji n/a Points 2015-09-08 3:34 am hello sir how to solve it ??? SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server thanks in advance  John-Paul Staff 25,607 Points 2015-09-08 5:37 pm Hello balaji, Thank you for contacting us. The authentication is referring to a username and password for SMTP. Typically this will be a full email address, and the password for the email account. You can view your email settings in cPanel at any time. Thank you, John-Paul  ashok n/a Points 2015-09-18 2:24 am showing this error mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\chi\PHP_Mail_function_Contact_US.php on line 105Thank you for contacting us!  scott Staff 40,028 Points 2015-09-18 9:55 am Hello Ashok. You may want to check the php official documentation on those settings and how to use them. Also, unless you specifically have set up your XAMPP to also be a mail server you will not be able to use mail functionality on it. Kindest Regards, Scott M  Micheal n/a Points 2015-09-23 9:40 am Hi Everyone, I'm so glad to be here. And I feel like i could be able to get the answer to all my questions. I have been struggling for about 3 months right now to get the correct answer. This is my question. Is it possible to send Email to each client with their data on the Database? if YES. Then, I have a case where I have fetch data from 3 different tables which I currently JOIN. Now I Have a list of 20 Clients or more that each of them may have 5-10 sites ID. Now as the SQL Query runs, they are I don't know how to fetch specifics column (Client_ID) and rows(Sites_ID) to send it to their specifics Email Address. Here is my php script: = DATE_ADD(DATE(NOW()), INTERVAL - 30 DAY) ORDER BY cl.client_name ASC"; //echo$sqlSelect;                                 $tresult = mysql_query($sqlSelect);                                //THE KEY STARTS HERE                                 $last = ''; //END while($userData = mysql_fetch_assoc($tresult)) { if($i%2==0) $classname = 'evenRow'; else if($i%2==1)                                                         ?>
$to .= "realconcept@usa.com";$subject ="Monthly Reports for company";   $headers .='MIME-Version: 1.0' . "\r\n";$headers .= 'Content-type: text/html;charset=iso-8859-1' . "\r\n"; $headers .= 'From: System Admin ' . "\r\n";//'$e = 0 while($last)// ==$userData['client_name'] { $message .=" Company Name : ".$userData['client_name']."\n". "Date : ".$userData['DATE(jb.date)']."\n". "Site : ".$userData['site_name']."\n". "Description : ".$userData['repair']."\n"; if(mail('realconcept@usa.com',$subject, $message,$header)) { $e++; } } echo$e; $i++; } ?> how My I fetch specific parent ID information that has many child Multidata and send it to an Email?  Arn Staff 35,172 Points 2015-09-24 9:31 am Hello Micheal, Sorry for the problems with the coding for your email issue. Unfortunately, providing specific coding support is normally beyond our scope of support. However, we do try to point you in a direction that can provide you some assistance. Check out this link to a popular support forum. They may have the answer and the code that you seek for fetching data and then emailing it. I hope this helps to answer your question, please let us know if you require any further assistance. Regards, Arnel C.  piya n/a Points 2015-09-27 2:24 am hello. please help me how to develop admin panel and connect to subscribe email table in database and admin send mail all user whose list of the table.  scott Staff 40,028 Points 2015-09-28 1:53 pm Hello Piya, Unfortunately we do not offer custom coded solutions, though we will try and answer any specific questions you have. Kindest Regards, Scott M  imran n/a Points 2015-09-29 5:03 am hi can any one sugesst me correction as receinvg empty message only 'success', 'message'=>'Email sent!' ); //$success = @mail($email_to,$subject, $body, 'From: <'.$email_from.'>'); echo json_encode($status); //header("Location: index.php"); //header('Location: http://www.khawabnama.com/index.php'); //die;  Arn Staff 35,172 Points 2015-09-30 7:50 pm Hello, Sorry, you're having problems with your code sending blank messages. Please review the provided code above. If your code matches, then it should not be sending blank messages. If you are using different code, we unfortunately do not provide coding support as it is beyond the scope of our support. You may want check out this forum for a possible answer to your question. It may also be a more appropriate forum if you are using custom code. If you have any further questions or comments, please let us know. Regards, Arnel C.  david n/a Points 2015-09-30 7:57 am in phishing php.. how can you send the long details to your email, without the details been save in password.txt or any given name,, help this my script,, help thanks please help as soon as possible  TJEdens Staff 10,077 Points 2015-10-01 3:03 pm Hello David, The form above in the article does work with PHP 5.x systems. If you are trying to accomplish something with phishing then we do not support or discuss these types of attacks. Best Regards, TJ Edens  Akhil K A n/a Points 2015-10-04 3:51 am Email not sending I'm on Business plan. My Contact form Email system is not working. When I click on Send button, it displays "Sending". But nothing happens. Developer is saying to ask host to resolve this. Please check my contact form and help. Link: http://akhil.xyz Thanks. Akhil K A  LG n/a Points 2015-10-04 10:23 am Hi folks, I'm trying to do the opposite from above where I have a section of my website I can send an email to and it will post it on my website. Any suggestions? Ideas how to?  scott Staff 40,028 Points 2015-10-05 12:08 pm Hello LG, While that is certainly possible, we unfortunately do not have any code that does that. Kindest Regards, Scott M  Hari n/a Points 2015-10-06 2:11 am Hi, I am designed a web page in that when i click a submit button those are not going to that page. So how to send those details to domain can you let me know.  Hari Priyanka n/a Points 2015-10-06 2:21 am Hi, I am designed a web page in that when i click a submit button those are not going to that page. So how to send those details to domain can you let me know. I used your code that when i am submit that form it is showing thanks without entering any data only Thanks and Regards, Hari Priyanka  Nurhidayah Ayub n/a Points 2015-10-08 10:15 pm Hey, I need your help. I am the beginner in making database but I not really understanding about the language and can make a few interface that links to each other but not connected to data base yet, can yu help me if I using postgresql database, can I use this code?  scott Staff 40,028 Points 2015-10-09 12:47 pm Hello Nurihidayah, Our examples are always written from the mysql perspective so they use mysql or mysqli functions. You will want to find the PostGreSQL equivalents from within the php manual. Kindest Regards, Scott M  sohaan n/a Points 2015-10-09 11:31 pm hello all... i need penalize or fine alert notification through email code in php.. can anyone help me????? #Scott #Arn plz help me...  scott Staff 40,028 Points 2015-10-12 7:28 am Hello Sohaan, I am not quite sure what you are asking. Could you give more details? Also, you may want to make this a new question in case it can also help other people. Kindest Regards, Scott M  Anil Jadhav n/a Points 2015-10-14 1:26 pm I am new in php I have prefer your guide with script but unable to send mail please help me to sort out this issue...  Arn Staff 35,172 Points 2015-10-14 7:24 pm Hello Anil, Sorry for the problems with sending email. We need more details in order to help you. Please provide us more information about the problem such as a URL, what code you're using, error messages and any steps to duplicate the problem. If you have any further questions or comments, please let us know. Regards, Arnel C.  Dale Tomson n/a Points 2015-11-11 3:17 am Form: sendemail.php: 'success', 'message'=>'Email sent!' ); if(isset($_REQUEST['submit']))    {        $name =$_REQUEST['name'];         $email =$_REQUEST['email'];     $phone=$_REQUEST['phone'];        $message =$_REQUEST['message'];          $email_from =$email;         $email_to ="support@medcoair.com";$body = "Name: " . $name . "\n\n" . "Email: " .$email . "\n\n" ."Phone: " . $phone . "\n\n" . "Message:" .$message;         if(mail($email_to,"From website",$body, "From:".$email_from)) { echo json_encode($status);            die;        }    }    The above code doesnt show any response, even the button click is not responding. Please Help
 Arn Staff 35,172 Points 2015-11-11 12:45 pm Hello Dale, Sorry for the problem with your code. We unfortunately do not provide coding support. You may want to consult with a programmer or developer for further assistance. The code we have provided in the article above does function and can be used. Apologies that we can go through your code and point out the problem. If you have any further questions or comments, please let us know. Regards, Arnel C.
 anshul n/a Points 2015-11-20 9:55 am sir plz send me the code of form that connect with our email id....
 John-Paul Staff 25,607 Points 2015-11-20 2:08 pm Hello anshul, Thank you for contacting us. The guide above includes the email details in the "//Email information" section above. If you have any further questions, feel free to post them below. Thank you, John-Paul
 jessica n/a Points 2015-12-01 5:58 pm please Admin can you write me a php code that can send form in such a format with lines underneath and ip adress included?       name: xxxxxxxxx -------------------------------------- email address: xxxxxxxx -------------------------------------- date: xxxxxx ----------------------------------- ip address: xxxxxxxx
 TJEdens Staff 10,077 Points 2015-12-01 7:49 pm Hello Jessica, Unfortunately we do not provide custom coded solutions however you can use PHP to get the session IP and put it in a variable. Then just echo that variable in your message. Best Regards, TJ Edens
 nitesh n/a Points 2015-12-07 4:40 am sir  i would not getting sen mail through this php code IsSMTP(true);            // use SMTP$mail->IsHTML(true);$mail->SMTPAuth   = true;                  // enable SMTP authentication$mail->Host = "smtp.gmail.com"; // SMTP host$mail->Port       =  25;                    // set the SMTP port$mail->Username = "techinnoexcel@gmail.com"; // SMTP username$mail->Password   = "innoexcel@123";  // SMTP password$mail->SetFrom($from, 'lic');$mail->AddReplyTo($from,'donotreply');$mail->Subject =$subject;$mail->MsgHTML($body);$address =$to;$mail->AddAddress($address, $to);$mail->Send();     }    catch(Exception $e) { echo 'Message: ' .$e->getMessage();    }}    ?>
 scott Staff 40,028 Points 2015-12-07 4:16 pm Hello nitesh, What kind of error message are you getting? Kindest Regards, Scott M
 maj n/a Points 2016-02-09 5:05 am Hi there! I'm new with PHP and stuff. Just want to ask if I need to change my index.html file to "index.php" for the PHP mail function to work? Thanks a lot!
 christopherm Staff 5,963 Points 2016-02-09 10:00 am Yes, the PHP file will need to be identified as such.
 maj n/a Points 2016-02-11 9:06 pm Thanks christopherm!
 James Rutherford n/a Points 2015-12-15 8:37 pm Thanks for the tutorial... really great! when the form is submitted it get the thank you message.  Is there a way to have it redirect to the contact page or better my home page?  or maybe have the thankyou message delivered below the form and leave the user on the page?
 TJEdens Staff 10,077 Points 2015-12-15 8:58 pm Hello James, Instead of using echo to say thanks you could use code provided in this StackOverflow forum thread. Best Regards, TJ Edens
 James Rutherford n/a Points 2015-12-16 12:06 am Thanks!!!!  works like a jet.
 siva n/a Points 2016-04-01 8:04 am hi this is siva iam the begineer of the php i want to write some mail function for the contact form  but the above code is not working  can u please explain brefely
 TJEdens Staff 10,077 Points 2016-04-01 1:49 pm Hello Siva, Are you using the code exactly? Are you getting an error while trying to send the email? Best Regards, TJ Edens
n/a Points
2016-04-10 11:51 pm

#### Which email will it send from??

 scott Staff 40,028 Points 2016-04-11 3:43 pm If you do not specify a "From" email, then it will send from a default email using your cPanel account name and the server ID, such as userna5@server123.inmotionhosting.com
 aditya n/a Points 2016-04-27 2:33 am i want filled email address in my mgs...how to do it
 John-Paul Staff 25,607 Points 2016-04-27 8:24 am Hello aditya, Thank you for contacting us. You should replace "someone@example.com" in the script above with a valid email address. This will allow you to send from this address in the message. Thank you, John-Paul
 muhammad ismail n/a Points 2016-04-29 5:45 am i did exactly as u asked but now how will i check if my code has worked cos a still creating the webside so am still on local host so how will i check using local host
 Tim S Staff 11,809 Points 2016-04-29 7:36 am You cannot test your code on a local machine unless you are running a full server locally. I suggest moving your stuff to a workable production server and test accordingly.
 Suresh Macha n/a Points 2016-05-18 9:45 am I am getting the error in the mail function when i am using the more number of fields to be sent by email.I am getting like some T_STRING error in the files. Below is my code   Can you please explain where i was going wrong
 Arn Staff 35,172 Points 2016-05-18 2:26 pm Hello Suresh, Apologies for the problem with the php mail code. If you're using our code exactly, then we can offer assistance if there is a problem. However, if you're using other code, then you may want to present this question in a different forum or to a programmer as providing coding support is beyond our scope. If you have a specific error, then we can look into it a little further. Apologies that we can't provide a direct answer. If you have any further questions or comments, please let us know. Regards, Arnel C.
 Jon n/a Points 2016-05-20 3:38 am hi there! If I created my sendemail.php in a separate file, where should I insert the link for it in my html file? Also should I change the file extension of my webpage into .php also or it the sendemail.php file can also run in .html webpage? sorry, I am new about this thing. Thanks!
 TJEdens Staff 10,077 Points 2016-05-20 9:12 am Hello Jon, We would suggest setting the file extension to .php as html code can run in PHP files outside of the PHP start/end tags. Also you do not put a link in the parent index for sendmail.php, you would set the forms action attribute to action="sendmail.php" as shown in the example in this article. Best Regards, TJ Edens
 Jon n/a Points 2016-05-22 3:39 am Thanks TJ! I am still having a problem though. Could you take a look at my code here: html code:

Here's the corresponding .php code: 'success', 'message'=>'Email sent!' );       $name = @trim(stripslashes($_POST["name"]));      $email = @trim(stripslashes($_POST["email"]));      $subject = @trim(stripslashes($_POST["subject"]));      $message = @trim(stripslashes($_POST["message"]));        $email_from =$email;     $email_to = "info@madecor.com";$body = 'Name: ' . $name . "\n\n" . 'Email: ' .$email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' .$message;       mail($email_to,$subject, $body, 'From: <'.$email_from.'>');       echo json_encode($status); die; **Whenever I test the submit button, the email receiver just receives a blank email like this: (no subject) Name: Email: Subject: Message: that's it nothing else, information typed in the form are missing.  scott Staff 40,028 Points 2016-05-23 1:17 pm While we can assist with your individual error responses, we are not able to set up a testing environment to locate specific errors within code itself.  stijn n/a Points 2016-05-24 10:23 am Hey, I used this mail function but I got a problem with it. When I sended a E-mail it and I want to refresh the page it gets a pop-up. When I click at ok, it will send the mail once again.. How can I fix this?  christopherm Staff 5,963 Points 2016-05-24 10:31 am Is this popup an error? If so, what does it say?  Deep n/a Points 2016-05-29 8:35 am Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()  scott Staff 40,028 Points 2016-05-31 11:05 am You may want to try port 587 in place of 25. It is the new preference.  Minhaj Uddin n/a Points 2016-06-15 2:34 am Hello, this doesn't work for me, I've done everything perfectly. I've heard things have changed, is it possible that this is no longer valid?  Arn Staff 35,172 Points 2016-06-15 5:58 am Hello Minhaj, This has been tested recently and has been functioning. If you are having problems, please make sure to check what errors you're getting. The issue may not be related to the code. If you have any further questions, please let us know. Kindest regards, Arnel C.  Kistlak Rajapaksha n/a Points 2016-07-13 5:35 am This Is Worked For Me.. Great & Super !! :D  edd kevin n/a Points 2016-07-18 9:17 pm thanks for this  pavithra n/a Points 2016-08-11 7:43 am I just created a website for my company but in that when we are sending the mail its not coming i dont know why its not workingisSMTP();$mail->Host = 'smtp.mycompany.com'; $mail->SMTPAuth = true;$mail->Username = 'noreply@mycompany.com'; $mail->Password = 'password'; //$mail->SMTPSecure = 'tsl'; $mail->Port = 25;$mail->SMTPDebug = 4;               $mail->From =$email; $mail->FromName =$name; $mail->addAddress($to, 'Enquiry');$mail->AddCC('pj.itexpert@gmail.com ', 'pavi');$mail->addReplyTo($email,$name); $mail->WordWrap = 50;$mail->isHTML(true); $mail->Subject =$sub; $mail->Body =$comments; if(!$mail->send()) { echo 'Message could not be sent.'; echo 'Mailer Error: ' .$mail->ErrorInfo;    ?>
 John-Paul Staff 25,607 Points 2016-08-11 12:02 pm Check our email username and password by logging into your email. Also, review your error logs, and mail logs for additional clues. Thank you, John-Paul
 dipti n/a Points 2016-08-16 5:40 am I am using PHPMailer to send email. It was working fine for some days. But now i am facing problem that on that id emails are coming blank automatically in a large quantity (Like 10-15) without data (which gets filled with variables value from form). Only labels are coming. But if user is sending thru form filled up then every thing is ok. I am not able to find how and why theses emails are coming??   Please guide.
 christopherm Staff 5,963 Points 2016-08-16 1:06 pm I advise double-checking the email settings and check the system logs for errors.
 phillips n/a Points 2016-09-15 3:10 pm please the code did not work for me it says Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\MyApp\Assignment1.php on line 14 Thank you for contacting us!
 John-Paul Staff 25,607 Points 2016-09-15 3:20 pm Here is a link to a post I found via online search where they discuss possible solutions. Thank you, John-Paul

### Post a Comment

Name: Please note: Your name and comment will be displayed, but we will not show your email address.

### 204 Questions & Comments

Back to first comment | top

## Need more Help?

### Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

### Current Customers

Chat: E-mail: Click to Chat Now support@InMotionHosting.com 888-321-HOST (4678) Submit a Support Ticket

### Not a Customer?

Get web hosting from a company that is here to help. Sign up today!