php mail not sending to outlook.com - php

my contact form is not sending emails to outlook.com
i have tested it on other email accounts and works just fine.
is there anything i can do to solve that issue?
my php code is the following
<?php
$to = 'xxx#xxx.gr';
$headers = 'Content-type: text/plain; charset=UTF-8' . "\r\n";
if(isset($_POST['fullname'])){
$subject1 = mysql_real_escape_string($_POST['fullname']);
$mail = mysql_real_escape_string($_POST['email']);
$message = mysql_real_escape_string($_POST['message']);
$subject = " $subject1 $mail";
mail($to, $subject, $message, $headers);
header("location: contact.php");
exit();
}
?>
thank you in advance

Related

Changing CGI-Mailer in PHP mail script [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 5 years ago.
I have a php script that sends an email from an HTML form. The issue is that the sender shows as CGI-Mailer in my inbox.
How can I set the sender address to be that of the sender and not CGI-Mailer?
<?php session_start();
if(isset($_POST['Submit'])) {
$youremail = 'info#complexny.com';
$fromsubject = $_POST['fname'];
$subject = $_POST['fname'];
$fname = $_POST['fname'];
$url = $_POST['url'];
$mail = $_POST['mail'];
$phone = $_POST['phone'];
$headers = "From: $mail \n";
$headers .= 'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$message = $_POST['message'];
$to = $youremail;
$subject = ''.$fromsubject. ' is interested in a project with you.';
$body = '
Client: '.$fname.'
Phone Number: '.$phone.'
URL: '.$url.'
E-mail: '.$mail.'
Message:
'.$message.'
';
echo "<p style='text-align:center'>Thank you for your feedback. We will be in contact shortly.<br/>Continue to <a href='/'>The Company/a></p>";
mail($to, $subject, $body);
} else {
echo "You must write a message. </br> Please go to <a href='/contact.php'>Contact Page</a>";
}
?>
You are not passing the additional_headers parameter to the mail function. Change the line with the call to mail to:
mail($to, $subject, $body, $headers);
I would suggest using PHPMailer rather than mail(). You can see how to do what you're after in the answer to this question: Setting replyTo field in email
Quoting from that question:
$this->phpmailer->AddReplyTo($replyEmail,$fromName); //this is email2#example.com
$this->phpmailer->SetFrom($fromEmail, $fromName); //this is email1#example.com
You can find more info on PHPMailer here: https://github.com/PHPMailer/PHPMailer

Hyperlink not getting displayed in Php mail

I'm trying to email a link thru PHPMail. Somehow link is showing as plain text in email.
I want that link should be clickable when received in email. Currently it is showing as plain code.
Below is the code, please help!
<?php
$name=$_POST['firstname'];
$email=$_POST['email'];
$phoneno=$_POST['phoneno'];
$com=$_POST['comment'];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
?>
Print Boss your receipt
<?php
//$link="hello.php?a=$name&b=$email&c=$phoneno&d=$com";
$to = "ketanjoshi1993#gmail.com";
//$from = $email;
$subject = "send email in pdf format";
$message = "<a href='#'>test</a>";
$email = mail($to,$subject,$message);
if( $email == true )
{
echo "sent";
}
else
{
echo "not sent";
}
?>
You forgot to use your headers in your mail call:
$email = mail($to, $subject, $message, $headers);
So you forget to add the headers
try adding it as
$email = mail($to,$subject,$message, $headers);
It will work
You forget to add the headers
You can do like this :
$email = mail($to,$subject,$message, $headers);
If you don't pass the header parameter in PHP mail() function , default headers will be set & your will be treated as simple text body.

Can't get php mail() to work

I've got Mamp running on my mac and trying to get mail() to work.
This is what I've got to work with.
$to = 'mymail#gmail.com';
$subject = 'The subject!';
$message = 'Hi there!';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= "X-Mailer: PHP/".phpversion();
$headers .= 'From: Test <test#test.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Mail it
if(mail($to, $subject, $message, $headers))
{ print 'success!'; }
else
{ print 'fail!'; }
?>
It just keeps on returning false. Any idea what I'm doing wrong?
Some settings with php/apache I need to check?
if you using your snippet on localhost, put on server and then try.
php mail() function needs to be on sever if you want it to work. on localhost you always get fail!
Try this:
<?php
$Name = "Da Duder"; //senders name
$email = "email#adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt#emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
ini_set('sendmail_from', 'me#domain.com');
mail($recipient, $subject, $mail_body, $header);
?>
http://be.php.net/manual/en/function.mail.php
each line of text may not be bigger than 70 chars and needs to be cut off with a LF (\n)
EDIT: as #brad suggested: SwiftMailer is realy good!

PHP Contact Form not Sending?

Ive got a contact form that isnt sending but is outputting that the message is sent? Can anybody see a problem?
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "myemail#email.co.uk";
//begin of HTML message
$message = "
From : $name,
Email: $email,
Subject: $subject,
Message: $message ";
//end of message
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Website Enquiry";
if (isset($_POST['name'])) {
// now lets send the email.
mail($to, $subject, $message, $headers);
header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=Thankyou, we will be in touch shortly.');
} else {
header('Location: ' . $_SERVER['HTTP_REFERER'] . '?e=There was an error sending your message, Please try again.');
}
?>
The "From" header should have a syntactically correct email address. You also need to check the return value of the "mail" function.
$header .= "From: Website Enquiry <enquiry#website.com>";
PS: Please improve your code formatting.
Try to enter an email at From: in $headers.
Like $headers .= "From: youremail#provider.com" or
$headers .= "From: Website Enquiry <youremail#provider.com>"
And you should change it to
if(mail(...)) {
//success
}
else {
//email failed
}

php mail function

<?php
$sendto = "account#gmail.com";
$subject = "email confirmation"; // Subject
$message = "the body of the email - this email is to confirm etc...";
# send the email
mail($sendto, $subject, $message);
?>
this is the code that i wrote to test mail function on localhost.
i have ran the script in browser for several times and still dun receive any email in my mail box.
Do I need any additional configurations?
thx in advance!
Basically is hard to send a mail from localhost to any mail providers.
They have big restrictions on the incoming mails, and the simply mail() won't work.
You need to use an SMTP server.
and define that server in php configuration
smtp = localhost #(here should be your smtp server)
smtp_port = 25
if you don't have an SMTP server, try to pass all headers like in PHP examples:
$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);
http://www.php.net/manual/en/function.mail.php
You need to make sure that you have your PHP installation set up to use a working SMTP Server. You might find what you're looking for in answers to this question. Failing that you'll likely need to test your script on your live web server.
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
?>
<?php
$email_from = 'yourname#yourwebsite.com';
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message"
?>
<?php
$to = "inspiretechpark#gmail.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
?>
<?php
$to = "name1#website-name.com, name2#website-name.com,name3#website-
name.com";
mail($to,$email_subject,$email_body,$headers);
?>
<?php
$to = "name1#website-name.com, name2#website-name.com,name3#website-
name.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
$headers .= "Cc: someone#domain.com \r\n";
$headers .= "Bcc: someoneelse#domain.com \r\n";
mail($to,$email_subject,$email_body,$headers);
?>
Try This Guys..This Is For Sending Mail
Try this:
<?php
$sender = 'email#example.com';
$recipient = 'email#example.com';
$subject = "php mail test";
$message = "php test message";
$headers = 'From:' . $sender;
if (mail($recipient, $subject, $message, $headers))
{
echo "Message accepted";
}
else
{
echo "Error: Message not accepted";
}
?>
If you are working with localhost then, i hope it will never work. It will work only on a mail configured server. Please try on it.

Categories