Trying to add attachment to PHP email from html form - php

I am seriously struggling and have tried so many different methods to get my form to attach a file to the email sent through PHP.
This is the HTML form:
<form id="form1" enctype="multipart/form-data" action="submit/applicationscript.php" method="post" name="form1">
<input checked type="radio" name="school" value="English Martyres"/>
<input type="radio" name="stop" value="stop1" />
<input type="radio" name="stop" value="stop2" />
<input type="radio" name="stop" value="stop3" />
<input type="radio" name="stop" value="stop4" />
<input type="checkbox" name="mon" value="Monday" />
<input type="checkbox" name="tue" value="Tuesday" />
<input type="checkbox" name="wed" value="Wednesday" />
<input type="checkbox" name="thu" value="Thursday" />
<input type="checkbox" name="fri" value="Friday" />
<input type="text" class="text" name="name" required placeholder="First Name" /></div>
<input type="text" class="text" name="surname" required placeholder="Surname" /></div>
<input type="text" class="text" name="dob" required maxlength="10" placeholder="Date of Birth" />
<input type="file" name='uploaded_file' required />
<input type="submit" id="form1" name="submit" value="Submit" onClick="document.form1.submit()">
</form>
This is the PHP:
<?php
// Read POST request params into global vars
$to = $_POST['my#email.com'];
$from = $_POST['from#email.co.uk'];
$subject = $_POST['subject'];
$message = $_POST['message'];
// Obtain file upload vars
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
$headers = "From: $from";
if (is_uploaded_file($fileatt)) {
// Read the file to be attached ('rb' = read binary)
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// Add the headers for a file attachment
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
// Add a multipart boundary above the plain message
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// Base64 encode the file data
$data = chunk_split(base64_encode($data));
// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
// Send the message
$ok = #mail($to, $subject, $message, $headers);
if ($ok) {
echo "<p>Mail sent! Yay PHP!</p>";
} else {
echo "<p>Mail could not be sent. Sorry!</p>";
}
?>
It either sends and does not attach an attachment or it is unable to send or the $message is empty and therefore does not send.
Cannot anyone please help me, really need this to work and don't have a great knowledge of PHP, have looked at so many articles but cannot get my head around it.

I use PHPMailer for this and I haven't had any issues.
Get it here: https://github.com/PHPMailer/PHPMailer
Here is an example:
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$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 encryption, 'ssl' also accepted
$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->WordWrap = 50; // Set word wrap to 50 characters
$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';
}

Related

PHP contact us from having issues sending mail to the id

I've been trying this for a long but failed till now.
I've tried changing form names, or attributes names but didn't work.
Here is the code for my form:
<form action="contact_process.php" class="office_contact_form" id="contactForm" method="post" name="contactForm" novalidate="">
<div class="form-group col-md-12">
<input class="form-control" id="name" name="name" placeholder="Name" type="text">
</div>
<div class="form-group col-md-12">
<input class="form-control" id="email" name="email" placeholder="Email Address *" type="text">
</div>
<div class="form-group col-md-12">
<input class="form-control" id="subject" name="subject" placeholder="Subject" type="text">
</div>
<div class="form-group col-md-12">
<textarea class="form-control" id="message" name="message" placeholder="Your Message" rows="1"></textarea>
</div>
<div class="form-group col-md-12">
<button class="btn p_btn" type="submit" value="submit">Send Message</button>
</div>
</form>
Here is my PHP code:
<?php
$to = "hello1224#gmail.com";
$from = $_REQUEST['yourname'];
$name = $_REQUEST['youremail'];
$headers = "From: $from";
$subject = "You have a message from your attornyeproducts.com";
$fields = array();
$fields{"yourname"} = "name";
$fields{"youremail"} = "email";
$fields{"subject"} = "subject";
$fields{"phone"} = "phone";
$fields{"message"} = "message";
$body = "Here is what was sent:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$send = mail($to, $subject, $body, $headers);
?>
I'm trying to receive the data from the this contact form to the email's id.
Did you tried https://github.com/PHPMailer/PHPMailer ?
simple example: https://github.com/PHPMailer/PHPMailer
example to fit your case:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // 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
//Recipients
$mail->setFrom("YOUREMAIL#gmail.com");
$mail->addAddress("hello1224#gmail.com"); // Add a recipient
$fields = array(
"yourname" => $_REQUEST['yourname'],
"youremail" => $_REQUEST['youremail'],
"subject" => $subject ,
"phone" => "phone",
"message" => "message",
);
$body = "Here is what was sent:\n\n"; foreach($fields as $a => $b){
$body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $subject
$mail->Body = $body;
$mail->AltBody = $body;
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
I did not test your fields. You can test your field to ensure they have correct values and then pass those values to this function.
I suggest you use FILTER_VALIDATE_EMAIL to ensure you have a valid email.
Also you can check that the post keys that you are expecting actually exist:
$message=(isset($_POST['message']))?$_POST['message']:'default message';
function send($subject,$msg,$email,$from,$replyto=null){
$replyto=(isset($replyto) && filter_var($replyto, FILTER_VALIDATE_EMAIL) )?$replyto:'contact#mydomain.com';
$params="-fcontact#mydomain.com";
$subject = $subject;
$message = "<div style='font-family: Arial, Helvetica, sans-serif;'>";
$message .= $msg;
$message .="</div>";
$headers = "From: =?utf-8?b?".base64_encode($from)."?= <contact#mydomain.com>\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= 'Bcc: info#mydomain.com' . "\r\n";
$headers .= 'Reply-To: '.$replyto . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion();
$to = $email;
if(isset($_SERVER['REMOTE_ADDR']) && in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ))) return true;
return mail($email, $subject, $message, $headers,$params);
}

php mail function works but i don't receive any mails [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 3 years ago.
I used mail() function to receive mail from customers who are visiting my web page I use this code for mail function (mail.php). I use this same code from the first it worked for me in the beginning but not working now.
<?php
if(isset($_POST['submit'])){
$to = "******";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>Enquiry</p>
<table>
<tr>
<td><strong>Name</strong></td><td>:</td><td>".$_POST['name']."</td>
</tr>
<tr>
<td><strong>Email ID</strong></td><td>:</td><td>".$_POST['email']."</td>
</tr>
<tr>
<td><strong>Mobile</strong></td><td>:</td><td>".$_POST['mobileno']."</td>
</tr>
<tr>
<td><strong>Message</strong></td><td>:</td><td>".$_POST['msg']."</td>
</tr>
</table>
</body>
</html>
";
// 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";
// More headers
$headers .= 'From: <****>' . "\r\n";
$headers .= 'Cc: *****' . "\r\n";
if(mail($to,$subject,$message,$headers)) {
echo '<script>
alert("Email Sent Successfully!");
window.location.href="../contact-us/contactus.html";
</script>';
} else {
echo '<script>
alert("Sorry your mail was not send kindly try again later.");
window.location.href="../contact-us/contactus.html";
</script>';
}
}
?>
here is my contact form code..
<form method="post" action="../mail/mail.php">
<p class="comment-form-author">
<label>Name<span>(required)</span></label>
<span class="icon-input">
<input type="text" name="name" required />
</span> </p>
<p class="comment-form-email">
<label>Email<span>(required)</span></label>
<span class="icon-input">
<input type="email" name="email" required />
</span> </p>
<p class="comment-form-mobileno">
<label>Mobile No.<span>(required)</span></label>
<span class="icon-input">
<input type="text" name="mobileno" required />
</span> </p>
<p class="comment-form-comment">
<label>Message<span>(required)</span></label>
<textarea name="msg">
</textarea>
</p>
<p class="form-submit">
<input type="submit" value="submit" name="submit">
</p>
</form>
when I click submit it shows me
"Sorry, your mail was not sent kindly try again later."
i would suggest you use PHPMailer for the same. For that you need to download the PHPMailer lib. It is available in github. Place the lib in your web-server folder. inside your if(isset($_POST['submit'])){ } write and change according to your need
$mail = new PHPMailer(); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true;// authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.gmail.com";//You can also use other smtp such as outloook<br> (oulook.office365.come)
$mail->Port = 465; // or 587 and 25 for outlook
$mail->IsHTML(true);
$mail->Username = "email#gmail.com";//Your Email Address
$mail->Password = "password";//Your Password
$mail->SetFrom("example#gmail.com");//Again Your Email email address
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddCC("CC#gmail.com");//if any cc (Set in if condifition if no cc)
$mail->AddAddress("email#gmail.com");//Email Address of the person you want to send to
if(!$mail->Send()) {
echo error here
} else {
echo "Message has been sent";
}

Phpmailler Post Method Not Working

I have php website when try to submit contact form Post method not working. All of form elements inside of index.html i'll share the codes with you. I'll be happy if you could help me
In HTML File (index.php)
<form id="main-contact-form" method="post" action="sendemail.php">
<div class="form-group">
<input type="text" name="name" class="form-control" placeholder="İsim Soyisim" required>
</div>
<div class="form-group">
<input type="email" name="mail_adress" class="form-control" placeholder="Mail Adresi" required>
</div>
<div class="form-group">
<input type="text" name="subject" class="form-control" placeholder="Konu" required>
</div>
<div class="form-group">
<textarea class="form-control" name="message" rows="8" placeholder="Mesaj" required></textarea>
</div>
<button type="submit" name="send" class="btn btn-primary">Mesaj Gönder</button>
</form>
in PHP (sendemail.php)
<?php
require 'PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'xx#xxxxx.com'; // SMTP username
$mail->Password = 'xxxxx'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->Port = 587; //Set the SMTP port number - 587 for authenticated TLS
$mail->setFrom('xxx#xxxxxx.com', 'xx xx xx'); //Set who the message is to be sent from
$mail->addAddress('xxx#xxxxx.com', 'xx xx xx xx'); // Add a recipient
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = $_POST['subject'];
$mail->Body = 'Mesaj Konusu'.$_POST['name'];
$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
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
echo $_POST['subject'];
exit;
}
echo 'Message has been sent';
?>
Thank You
Try to compare with the === operador, to compare not only the same value, but also the same data type.
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// …
}
I found the answer ajax prevent to POST method when i fix that everthings are became good
var form = $('#main-contact1-form');
form.submit(function(event){
event.preventDefault();
var form_status = $('<div class="form_status"></div>');
$.ajax({
url: $(this).attr('action'),
beforeSend: function(){
form.prepend( form_status.html('<p><i class="fa fa-spinner fa-spin"></i> Mail Gönderiliyor...</p>').fadeIn() );
}
}).done(function(data){
form_status.html('<p class="text-success">Mesajınız başarı ile iletilmiştir. En kısa sürede tarafınıza dönüş yapılacaktır.</p>').delay(3000).fadeOut();
});
});
when i delete this code everythings are good. How to fix that without delete it..? That's a new question to ask...
<?php
function sendmail($to,$subject,$message,$from)
{
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70, "\r\n");
$headers = "From: $from" . "\r\n" .
"Reply-To: $from" . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$headers = "From: " . $from. "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
}
?>
you write ==POST(capital letters), and use method = post(small letters), so change it to small or capital in both places. or check sendmail.php

php form - godaddy economic hosting Linux

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).

PHP form loads blank page and nothing happens?

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

Categories