PHP - "sendmail_from" not set in php.ini - php

Setting xampp to be able to send emails through the localhost. Used this guys instructions http://www.root25.com/2014/04/send-email-using-xampp-from-localhost.html and it was pretty straight forward.
It comes up with an error message:
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:"
header missing in C:\xampp\htdocs\process.php on line 56
PHP CODE
if (!($formerrors)) :
$to = "email#email.com";
$subject = "From $myname -- Contact/Booking Page";
$message = "$myname filled out the form";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: Patrick <email#email.com>' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$replyto = "From: $email \r\n".
"Reply-To: secondemail#email.com" . "\r\n";
if (mail($to, $subject, $message, $headers)):
$msg = "Thanks for filling out our form";
else:
$msg = "Problem sending the message";
endif; // mail form data
endif; // check for form errors
Not sure what the problem is here. Any advice?

Related

How to check if mail was send or not using php?

How to check if mail was send or not using php ?
I use this code for send email using php. It's work good.
But i want to check email send success or not, How can i do that ?
<?PHP
$to = "test#mail.com";
$subject = "test subject";
$message = "test message";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: SENDER <noreply#sender.com>' . "\r\n";
$headers .= 'Return-Path: return#sender.com' . "\r\n";
mail($to, $subject, $message, $headers, '-freturn#sender.com');
?>

how to change the from attribute to my email in mail() function

I am trying to send an email to my customers when they place an order on my website. But the from appears like this:
From : n9da2313
I need to exchange it with info#awraq.me
I tried this but didn't work
`
$to = "founder#awraq.me";
$subject = "Your order";
$message = "Your order was placed successfuly";
$headers = "From: info#awraq.me";
$headers .= "\r\nReply-To: info#awraq.me";
$headers .= "\r\nX-Mailer: PHP/".phpversion();
mail($to,$subject,$message,$headers,"-f info#awraq.me");
`
try this-
$to = "somebody#example.com, somebodyelse#example.com";
$subject = "HTML email";
// 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: <webmaster#example.com>' . "\r\n";
$headers .= 'Cc: myboss#example.com' . "\r\n";
mail($to,$subject,$message,$headers);
If its not working then check if you have done some configuration in php.ini file.

PHP - Not receiving email from contact form

I am not receiving emails from this contact form, but the message seems to sending okay and it also redirects me to the sent page.
I don't have access to the server only via FTP.
PHP
<?php
$to = 'test#gmail.com';
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$comment = $_POST['comment'];
$body = <<<EMAIL
<html>
<p><h3>Email Submited From Website.</h3></p>
<p><strong>Name:</strong> $name</p>
<p><strong>Email:</strong> $email</p>
<p><strong>Subject:</strong> $subject</p>
<p><strong>Message:</strong> $comment</p>
</html>
EMAIL;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: test email' . "\r\n";
$headers .= 'From: <website#mt.co.uk>' . "\r\n";
//$headers .= 'Cc: noreply#example.com' . "\r\n";
//$headers .= 'Bcc: noreply#example.com' . "\r\n";
if ($_POST['submit']){
mail($to, $subject, $body, $headers);
header ("Location: message-sent.php");
die();
} else {
header ("Location: message-failed.php");
die();
}
?>
Check if mail is actually being sent:
if (mail($to, $subject, $body, $headers)===false) {
echo "Not sent!";
} else {
echo "Sent!";
}
Change this:
$headers .= 'To: test email' . "\r\n";
$headers .= 'From: <website#mt.co.uk>' . "\r\n";
To this:
$headers .= "To: $to <test email>\r\n";
$headers .= "From: website#mt.co.uk <website#mt.co.uk>\r\n";
Also, you need to sanitize the subject and body of the email so that the email arrives, but this will usually be reflected in the results after email() reports a success, in that case the email will bounce, go to the spambox, or simply be refused.
If your hosting provider doesn't have an email server, you could try to use a free email server and phpMailer. https://github.com/PHPMailer/PHPMailer

Multiple php email issue

For my project I had to create a function that sends two email. One to the customer and the other to the a seller. Both emails will have different contents.
I wrote the two function using the standard PHP mail function as below.
$to = "xxxx#xxxx.com";
$subject = 'xxxx';
$message = "hello"
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
Now, While testing the system on my own company's web server both emails seems to be sent and received. However, when I migrated the same system into an external server. only one email gets sent. primarily, the first email in the stack.
While I suspect the issue has something to do with the later server configuration, I am wondering where should I go next to debug this issue.
There were a few things in your "posted" code that were missing.
A missing semi-colon at the end of $message = "hello" (unless that was a typo/paste error?) and a dot in the first $headers
Also, not having a From: header attribute will surely result having the Email sent to and regarded as SPAM.
Having fixed those issues and added extra header information, the following code worked and did not end up in my SPAM, but the INBOX successfully.
<?php
$to = "xxxx#xxxx.com";
$email = "email#example.com";
$subject = 'xxxx';
$message = "hello";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $email" . "\r\n" .
"Reply-To: $email" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
mail($to, $subject, $message, $headers);
?>
Or with a success echo'ed message:
<?php
$to = "xxxx#xxxx.com";
$email = "email#example.com";
$subject = 'xxxx';
$message = "hello";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: $email" . "\r\n" .
"Reply-To: $email" . "\r\n" .
"X-Mailer: PHP/" . phpversion();
if(mail($to, $subject, $message, $headers))
{
echo "Message sent.";
}
else{
echo "Something went wrong.";
}
?>
Visit the PHP.net website for more information on the mail() and header() functions.
http://php.net/manual/en/function.mail.php

Sending mail failed in php

I am trying to send email using mail function in php:
$subject = 'testing';
$email = 'test#gmail.com';
$message = 'test message';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: The test site" . "\r\n";
if (mail($email, $subject, $message, $headers)) {
$data['msg']="Message send successfully";
}
else {
$data['msg']="Please try again, Message could not be sent!";
}
I Encounter following error:
A PHP Error was encountered
Severity: Warning
Message: mail() [function.mail]: SMTP server response: 501 Syntax error in parameters or arguments
Filename: sendemail.php
Line Number: 40
I might guess that error was due to not setting configuration required for sending email in php. What should I need to do or I have to change in php.ini file but it's not accesible. Any solution please?
$subject = 'testing';
$email = 'test#gmail.com';
$message = 'test message';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: The test site" . "\r\n";
$to=$toEmail;
$subject=$sub;
$from="info#mypropick.com";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "From: <".$from.">\n";
$headers .= "X-Priority: 1\n";
$message='<div style=" width:700px; margin:0 auto; border:1px solid #e2e2e2; padding:20px;">
<h3>MYPROPICK Services:</h3>'.$msg.'</div>';
$message .= "<br/>Regards <br />MYPROPICK.COM";
if (mail($to, $subject, $message, $headers )) {
$data['msg']="Message send successfully";
}
else {
$data['msg']="Please try again, Message could not be sent!";
}
You forgot a closing apostrophe in the code
$message = 'test message;
should be
$message = 'test message';
a quotes " ' " missed in 3rd line
$message = 'test message' ;
^
try :
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: valid#email.com" . "\r\n";
'From' must be a valid email address
SMTP Error 501 : Syntax error in parameters or arguments (e.g. invalid email address)
The command was correct and recognized, but the parameters (the arguments, e.g. email address) were not valid. For example you try to use invalid email address as sender\#domain.com and as "\" is not allowed in email addresses.
http://info.webtoolhub.com/kb-a15-smtp-status-codes-smtp-error-codes-smtp-reply-codes.aspx

Categories