Reply to email not working in php - php

I want to replace default webmaster email from my email it's not working in php script.
I have tried reply-to but it's not working
This is my php code.
$headers= "Reply-To: my#email.com\n";
mail($to,$subject,$body,$headers);

Try a simple structure (source: PHP.net - mail())
<?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);
?>

i don't know about your php-version, but mine doesn't like spaces when concatenetating with .=
try to remove the space here:
$headers .= "Reply-To: my#email.com\n";
so you get:
$headers.= "Reply-To: my#email.com\n";
(giving us information about whether you are getting an error-message and if so, which one - would have helped quite a lot, when my suggestion is right)

Related

Extra slash on email subject

I use this sample of code to send email from php
<?php
$to = 'nobody#example.com';
$subject = $_POST['subject']; //"the \test subject's";
$message = $_POST['body']; //'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
but when i recieve the email the subject displayed like that
the \\test subject's
How to remove this extra slash ?
Thanks
From http://php.net/manual/en/function.mail.php :
subject
Subject of the email to be sent.
Caution Subject must satisfy ยป RFC 2047.
RFC 2047 : http://www.faqs.org/rfcs/rfc2047.html
Wish it will help you.

PHP - Not Sending Emails with Header Information

I am having a problem sending emails when I add header information.
However when I just remove the header parameter it works. What is wrong? Is it the code? Or some setting I need to change on the web server admin panel to say "Allow-Headers" or something?
I am trying to send to hotmail in case this has any relavance in determining the problem.
Any help would be greatly appreciated. Thanks.
Below Doesn't Send Email:
<?php
$to = 'iputmyrealemailhere#hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com';
mail($to, $subject, $message, $headers);
?>
Below Sends Email:
<?php
$to = 'iputmyrealemailhere#hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com';
mail($to, $subject, $message);
?>
I use these headers in my php mailing function and it works well. Note: I also use a third party mail-routing service to avoid having my mails marked as coming from a spammy IP. You might want to look into that also.
$headers = 'From: '.$from.'#foo.net' . "\r\n" .
'Reply-To: '.$from.'#foo.net' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n";
I also use the optional fifth parameter to mail() to set the envelope address, e.g.:
$parameters = '-f '.$from.'#foo.net';
so the final call is:
mail($to, $subject, $message, $headers, $parameters);
You can just delete the "FROM:" from the headers list .. it prevents it in some hosts .But the real question then will be how ca I change the sent from email address to a specific email that I want

Sending Email in PHP from a button

Let me start by saying I do not have a lot of programming knowledge. I use a program called PHPRunner to generate most of the php that I do. It is mainly for small office stuff nothing fancy.
My question is:
I have a table that has 6 fields one of them called email. When I go into a record I wanted to put a button called "send notification" that would email the record details to the email address associated with that record.
Any help would be greatly appreciated. I know it is probably out here on the web, possibly searching the wrong way.
You can use the mail function in php. Example from the provided link:
<?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);
?>
For sending email using PHP, use mail() function
http://php.net/manual/en/function.mail.php
Example:
<?php
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$from = 'webmaster#example.com';
$headers = 'From: '.$from . "\r\n" .
'Reply-To: '.$from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>

Error in Sending Email using php

I am sending email using php script and i am setting from address as
$headers = "MIME-Version: 1.0" . "$from" . "\r\n";
$headers.= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
So, the mail coming to my mail address as from support#mysite.com, But i need to set from address as support#gmail.com.But it is not coming with the modified from address. So, please help to solve this problem..
You try this...
<?php
$to = 'nobody#example.com';
$subject = 'Mail Subject';
$message = 'Test';
$headers = 'From: support#gmail.com' . "\r\n" .
'Reply-To: support#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
Hop this will works...
Replace header text,
$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=UTF-8' . "\r\n";
$headers .= "X-Mailer: PHP \r\n";
$headers .= "From: YourName <support#gmail.com>";
To get more information about mail function
may this help you.

how to send email where "from" having 'firstname'<space>'lastname'<email_id> in php

i have to send email where email "from" having 'firstname''lastname'.
For ex: first_name="john"
last_name="Dime"
email_id="john#john.com"
then from should be like this in the sent mail: From: john dime.
Please help me if u find any solution.
As per RFC 2822, you simply need to set a header of the form...
From: John Dime <john#john.com>
...in the headers portion of your email.
I have found instances of mail not being delivered correctly if the from address is not specified using the -f option with sendmail:
<?php mail($email, $subject, $body, $headers, "-f $email") ?>
Yes simply write your name in "FROM" portion like given below
$headers = 'From: Fname Lname<webmaster#example.com>' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
This is taken from php.net website:
<?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);
?>
You can specify the from field in the additional headers.
You just need to change the webmaster#example.com with the desired string
http://php.net/manual/en/function.mail.php - this can be useful for you

Categories