Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have created an HTML form, and some part of a PHP script. Look below.
I need, somehow, to send the form, using the mail function. How do i do this?
HTML:
<form id="kontaktForm" action="Scripts-ContactForm/recieving.php" method="POST">
<div id="kontaktFormVenstre">
<div id="inputFields_container">
<div id="inputField_container">
<input class="inputField" type="text" name="name" placeholder="Dit navn" />
</div>
<div id="inputField_container">
<input class="inputField" type="text" name="email" placeholder="Din E-Mail" />
</div>
</div>
<div id="inputFieldMessage_container">
<textarea class="inputFieldMessage" name="message" placeholder="Din besked her" rows="8" cols="20"></textarea>
</div>
</div>
<div id="kontaktFormHøjre">
<div id="button">
<input type="submit" name="submit" value="Send mail" />
</div>
</div>
</form>
PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'Fra:'$email;
$to = 'MyEmail';
$subject = 'Hello';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
?>
You can send mail like this. Use PHP mail() function.
<?php
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'Fra:'$email;
$to = 'MyEmail';
$subject = 'Hello';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
mail($to,$subject,$body,"From:$from");
}
?>
Your better off using something like PHPMailer, you can download it from: https://github.com/PHPMailer/PHPMailer
There are many examples to help you get started, but using this you can generate HTML emails and HTML alternatives ( for clients that cant read html )
example from github:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->From = 'from#example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('joe#example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen#example.com'); // Name is optional
$mail->addReplyTo('info#example.com', 'Information');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/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 <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
as an alternative you can use PHP's mail() function and as said above its as simple as using:
if(mail('toemail', 'subject', 'message', 'headers')) {
echo 'Mail has sent';
} else {
echo 'Mail not sent';
}
http://php.net/manual/en/function.mail.php
Try this:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = 'MyEmail';
$subject = 'Hello';
$headers = 'From: '.$name.' <' . $email . ">\r\n" .
'Reply-To: '.$name.' <' . $email . ">\r\n";
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
mail($to, $subject, $body, $headers);
Related
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
HTML Form with Sendemail
(2 answers)
Closed 5 years ago.
I have only dabbled in PHP a little, I am trying to remember what I did last year. I am having trouble getting this to work - the user is redirected to index.php but then nothing happens. No email is recieved and no verification 'email sent/not sent' etc.
I am sure it is probably a silly mistake.
Any help would be appreciated.
contact.html
<form method="post" action="index.php">
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<label>*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
index.php
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = $_POST['email']; // GET EMAIL ADDRESS FROM FORM
$to = 'annie.palmer#outlook.com';
$subject = 'Website enquiry from' .$name;
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
$headers = "From: Annie<$from>\r\nReturn-path: $from" . "\r\n";
$headers .= "Content-type:text/text;charset=ISO-8859-1";
?>
<?php
if ($_POST['submit'] && ($_POST['human'] == '4') {
/* Anything that goes in here is only performed if the form is submitted */
if (mail ($to, $subject, $body, $headers, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
I'm posting this as a community wiki; I don't feel any rep should come of this, nor do I want rep.
mail() uses 4 arguments, not 5.
http://php.net/manual/en/function.mail.php
There is a 5th but it doesn't do what you're expecting your 5th to do.
So remove the , $from from this:
if (mail ($to, $subject, $body, $headers, $from))
^^^^^^^
The From: belongs in the header and expects an email address.
Example from the manual:
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Try using the PHPMailer. Once uploaded to your site sending an email is easy.
require ('../mail/PHPMailerAutoload.php');
require ('../mail/class.phpmailer.php');
//set up your email
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tbs'; //set as required
$mail->Host = "enter your email host here";
$mail->Port = 25;
$mail->Username = "enter your mail account username here";
$mail->Password = "enter your mail account password here";
$mail->From = "the from email address";
$mail->FromName = "the from name";
$mail->Subject = "the subject goes here";
$mail->IsHTML(true); //your choice
$body = "the body of you email - html or plain text";
$mail->Body = $body;
$mail->AddAddress("add the email address(es) of recipients");
$mail->Send();
Update: My send.php now looks like this and when i click send got a blank page and send nothing. I have the class.phpmailer.php in the right place.
<html>
<head>
<title>PHPMailer - SMTP basic test with authentication</title>
</head>
<body>
<?php
error_reporting(E_STRICT);
date_default_timezone_set('America/Toronto');
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.******.hu"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.******.hu"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "support#******.hu"; // SMTP account username
$mail->Password = "******"; // SMTP account password
$mail->SetFrom('support#******.hu', 'First Last');
$mail->AddReplyTo("support#******.hu","First Last");
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$address = "support#******.hu";
$mail->AddAddress($address, "support#******.hu");
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$address = "support#******.hu";
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$formcontent= eregi_replace("[\]",'',$formcontent);
$mail->MsgHTML($formcontent);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
Helo!
I want to send a html form in email with this php code but not working...
I don't know why... If you know the solution please help me :)
Thank you!
The HTML form:
<div id="stylized" class="myform">
<form id="form1" action="send.php" method="POST">
<label>Név
<span class="small">Kérem adja meg nevét</span>
</label>
<input type="text" name="name">
<label>Email
<span class="small">Kérem valós címet adjon meg</span>
</label>
<input type="text" name="email">
<br />
<br />
<label>Telefon
<span class="small">Visszahíváshoz adja meg telefonszámát</span>
</label>
<input type="text" name="phone">
<br />
<br />
<label>Elérhetőség
<span class="small">Kérem adja meg mikor érhetjük el telefonon</span>
</label>
<select name="priority" size="1">
<option value="Low">Délelőtt</option>
<option value="Normal">Délután</option>
<option value="High">Este</option>
<option value="Emergency">Egész nap</option>
</select>
<br />
<br />
<br />
<label>Szolgáltatás
<span class="small">Mivel kapcsolatban keres minket?</span>
</label>
<select name="type" size="1">
<option value="update">Szolgáltatás Megrendelése</option>
<option value="change">Szolgáltatás Lemondás</option>
<option value="addition">Információ</option>
<option value="new">Hiba Bejelentése</option>
</select>
<br />
<br />
<br />
<label>Tárgy
<span class="small">Írja le az üzenet tárgyát</span>
</label>
<input type="text" name="website">
<br />
<br />
<br />
<label>Üzenet
<span class="small">Írja le üzenetét</span>
</label>
<textarea name="message" rows="15" cols="29"></textarea><br />
<button type="submit" value="Send" style="margin-top:15px;">Küldés</button>
<div class="spacer"></div>
</form>
</div>
And my php:
<?php
//error_reporting(E_ALL);
error_reporting(E_STRICT);
$mail = new PHPMailer();
$formcontent = eregi_replace("[\]",'',$formcontent);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "mail.myserver.hu"; // SMTP server
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "mail.myserver.hu"; // sets the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "support#myserver.hu"; // SMTP account username
$mail->Password = "myserverpass"; // SMTP account password
$mail->SetFrom('email#myserver.hu', 'First Last');
$mail->AddReplyTo("email#myserver.hu","First Last");
$mail->Subject = "test";
$mail->AltBody = "test"; // optional, comment out and test
$mail->MsgHTML($formcontent);
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$address = "email#myserver.hu";
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
</body>
</html>
Please help me if you can! :) Thaks!
You might want to add $mail->SMTPSecure = "ssl";
You can use mail basic function PHP... with this short code:
Class Mailer{
public static function sendMailNewUser($username,$firstname,$lastname,$password){
$to = $username;
$from_name = "INFO MAIL";
$from_mail = "noreply#mail.it";
$subject = "New User";
$uid = md5(uniqid(time()));
// header
$header = "From: ".$from_name." <".$from_mail.">\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=utf8\r\n";
$message = "Welcome $firstname $lastname, ";
$message .= "<br><br>";
$message .= "This is your account:<br>
<b>username: $to<br>
password: $password</b><br>";
mail($to, $subject, $message, $header);
}
}
You just made one mistake you need to put all variables before use them, like this :
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$call = $_POST['call'];
$website = $_POST['website'];
$priority = $_POST['priority'];
$type = $_POST['type'];
$message = $_POST['message'];
$address = "email#myserver.hu";
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website: $website \n Priority: $priority \n Type: $type \n Message: $message";
$formcontent= eregi_replace("[\]",'',$formcontent);
$mail->MsgHTML($formcontent);
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
This is my php code to send email. I got the massage 'Message was sent, you can send another one' But email is not sending.
<h4>Please fill out the following form and we will be in touch with you soon.</h4>
<form action="mytest.php" method="post" id="contactform">
<ol>
<li>
<label for="name">Your Name <span class="red">*</span></label>
<input id="name" name="name" class="text" />
</li>
<li>
<label for="email">Your email <span class="red">*</span></label>
<input id="email" name="email" class="text" />
</li>
<li>
<label for="subject">Subject</label>
<input id="subject" name="subject" class="text" />
</li>
<li>
<label for="message">Message <span class="red">*</span></label>
<textarea id="message" name="message" rows="6" cols="50"></textarea>
</li>
<li class="buttons">
<input type="image" name="imageField" id="imageField" src="images/send.gif" class="send" />
<div class="clr"></div>
</li>
</ol>
</form>
<?php
if(!$_POST) exit;
$email = $_POST['email'];
$errors=0;
if($errors==1) echo $error;
else{
$email_from = $_POST['email'];
$email_from = "from#gmail.com";
$headers = "From: " . strip_tags( $_POST['name'] ) . "\r\n";
$mail_to_send_to = "to#gmail.com";
$your_feedbackmail = "from#gmail.com";
$sendflag = 'send';
if ( $sendflag == "send" )
{
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $your_feedbackmail" . "\r\n" . "Reply-To: $email" . "\r\n" ;
$a = mail( $mail_to_send_to, "Feedback Form Results", $message, $headers );
if ($a)
{
print("Message was sent, you can send another one");
} else {
print("Message wasn't sent, please check that you have changed emails in the bottom");
}
}
}
?>
I'm Using Cpanel to host my web site. Is there any special configurations to do this? I'm new to php. Please help me.
mail function doesn't provide authentication functionality. Your have to use Mail class from Mail Pear package. See here for an example:
example
I am assuming you are on shared hosting based on the fact that you are using Cpanel, some shared hosting solutions don't play nicely with php's mail() function, I have found that using phpmailer https://github.com/PHPMailer/PHPMailer works better and provides more functionality
to use phpmailer :
download from the link, place the files in your a folder accessible to your web application.
code :
$email_from = $_POST['email'];
$email_from = "from#gmail.com"; // this overwrites the $_POST['email'] value, check this
$email_from_name = "Nishanthi";
$gmailUsername = "from#gmail.com";
$gmailPassword = "mysecretpassword";
$mail_to_send_to = "to#gmail.com";
$your_feedbackmail = "from#gmail.com";
$emailSubject = "Place Subject Here";
$emailContent = "This message can contain <b>HTML</b>";
require '[path_to_your_phpmailer_files]/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
// 0 = off (for production use)
// 1 = client messages
// 2 = client and server messages
$mail->SMTPDebug = 2; //Enable SMTP debugging
$mail->Debugoutput = 'html'; //Ask for HTML-friendly debug output
$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = $gmailUsername; // SMTP username
$mail->Password = $gmailPassword; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom($email_from, $email_from_name);
$mail->addAddress($mail_to_send_to);
$mail->addReplyTo($your_feedbackmail);
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $emailSubject;
$mail->Body = $emailContent;
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message was sent, you can send another one';
}
?>
i have this form:
<form action="/sendemail.php" id="main-contact-form" method="post" name="contact-form" role="form">
<div class="form-group">
<input class="form-control" id="name" name="name" placeholder="put your name" required="" type="text" />
</div>
<div class="form-group">
<input class="form-control" id="email" name="email" placeholder="Email" required="" type="email" />
</div>
<div class="form-group">
<input class="form-control" id="subject" name="subject" placeholder="Subject..." required="" type="text" />
</div>
<div class="form-group">
<textarea class="form-control" name="message" placeholder="Mensaje" required="" rows="8"></textarea>
</div>
<input class="btn btn-primary" id="submit" name="submit" type="submit" value="Enviar" />
and this is sendemail.php:
<?php
$pos = $_POST;
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = $_POST['email'];
$to = 'email#gmail.com ';
$subject = 'contact message ';
$body = "From: $name\n E-Mail: $email\n Message:\n $message\n $pos";
mail ($to, $subject, $body, $from)
?>
the email is arrive empty, i try a lot of stuffs but always comes in the same way, is like the form can´t pass the data from inputs to php variables. im new in php so, any help is welcome.
thanks.
The use of mail() function is so insecure and is a vector attack to send massive spam, don't use anymore, for this reason is better to use PHP Mailer libray.
Create a EMAIL account (example: no-reply#domain.com) in your hosting and after that install this library PHP Mailer, now you can do this:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('from#example.com', 'Mailer');
$mail->addAddress('joe#example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen#example.com'); // Name is optional
$mail->addReplyTo('info#example.com', 'Information');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/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 <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
UPDATE
After some research I've found that:
You need to ask godaddy technical support to enable "sendmail".
PHP mail() not working on GoDaddy
----------
I've tested your code and it works. I've received the email with ALL the $_POST contents without any problems.
$pos = $_POST;
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = $_POST['email'];
$to = 'email#gmail.com ';
$subject = 'contact message ';
NOTE:
1 - $pos = $_POST; is an array and it will be displayed as Array.
2 - Emails sent via mail() will most likely end-up on the spam folder (read the comments below).
I've tried out a few PHP contact form tutorials but none seem to work for me. I'm not sure what I'm doing wrong. I tested it in localhost and nothing, so I went ahead and hosted it to see if that would work but still nothing.
HTML
<form class="form" action="form_process.php" method="post" name="contact_form">
<p class="name">
<label for="name">Name</label><br>
<input type="text" name="name_first" id="name" placeholder="First" />
<input type="text" name="name_second" id="name" placeholder="Last" />
</p>
<p class="email">
<label for="email">Email</label><br>
<input type="text" name="email" id="email" placeholder="mail#example.com" />
</p>
<p class="text">
<label for="email">Comments</label><br>
<textarea name="text" placeholder="Write something to us" /></textarea>
</p>
<p class="submit">
<input type="submit" value="Send" />
</p>
</form>
form_process.php
<?php
$name_first = $_POST['name_first'];
$name_second = $_POST['name_second'];
$email = $_POST['email'];
$text = $_POST['text'];
$from = 'From: ';
$to = 'EMAIL HERE';
$subject = 'Hello';
$body = "From: $name_first\n $name_second\n E-Mail: $email\n Message:\n $text";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
header("Location: index.html");
echo '<p>Your message has been sent!</p>';
exit;
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
Your error is from the line
if ($_POST['submit']) {
This is because you did not give your submit button a name of submit. If you fix this line in your HTML it should fix the issue:
<input type="submit" name="submit" value="Send" />
I recommend that you set an error log in your php.ini file. That way you can see the error for yourself which would have said something similar to:
PHP Notice: Undefined index: submit in
/var/www/pwd/blah/form_process.php on line 12
If you are working in localhost mode you will need phpmailer.
First you need download phpmailer from here https://github.com/PHPMailer/PHPMailer/archive/master.zip
Then paste in your folder. If my coding doesn't clear you, you can check from
https://github.com/PHPMailer/PHPMailer
<?php
require 'PHPMailerAutoload.php'; // Your Path
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // Your mail
$mail->Password = 'secret'; // Your mail password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;
$mail->From = 'from#example.com';
$mail->FromName = 'Mailer';
$mail->addAddress('joe#example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen#example.com'); // Name is optional
$mail->addReplyTo('info#example.com', 'Information');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/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 <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
//Check Condition
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}
Second way.
If you working testing in online mode(Have own domain and hosting), you can just randomly copy and paste.
Doesnt required phpmailer.
if(isset($_POST['email'])) $email = $_POST['email'];
else $email = "";
function send_mail($myname, $myemail, $contactname, $contactemail, $subject, $message) {
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"".$myname."\" <".$myemail.">\r\n";
return(mail("\"".$contactname."\" <".$contactemail.">", $subject, $message, $headers));
}
if(isset($Submit) && $Submit=="Go") {
$emailContent ='';
$sent=send_mail($name, "yourmailname.gmail.com", "Fido", $receipientEmail, "Testing", $emailContent);
if($sent) {
echo $emailContent;
header('Location: contact.php');
}else{
echo "Failed";
exit;
}
}
?>
Regards