The line of code below is part of the form-mailer that processes the form on my Website. Whenever I receive an E-mail from the form, I can't see the name of the sender until I open the email because it displays(Inbox display) just the E-mail address and the Subject. How do I get it to display the Name and the Subject(Inbox display), so that I'll know the sender before I open it. I'd also like it to be reply-ready, So it replies to the sender's email When I Click on reply.
$message = "\n$fname submitted the following message:\n\n$message\n\n$fname's contact details are as follows:\n\nFirst Name: $fname\nLast Name: $lname\nPhone Number: $phone\nEmail Address: $email\n";
mail($mailto, "$subject", $message, "From: $email");
?>
mail($mailto, $subject, $message, "From: Person's Name<$email>" );
It can be solved in this way also:
A) In Your Code:
$mail->FromName = "Name Of Mailer";
B) In Phpmailer:
public $FromName = 'Terasoft'; //Root User
Hope this May work For you.
Related
I am beginner to php and ajax. Could you please help me how to send an email using php. Your help will be much appreciated. Thanks in advance.
Below is my required.
Logged in user details to AC Dealers and dealers content to logged in user.
The below image content should sent to logged in user details to the AC Dealer email id.
Well, sending an Email in PHP is pretty easy.
Sending from the server to an recipient:
$recipient = "dealer#market.com";
$subject = "This is a very important subject";
$message = "This is the Email body with your data";
mail($recipient, $subject, $message);
Sending from a specific Email to an recipient
$recipient = "dealer#market.com";
$subject = "This is a very important subject";
$message = "This is the Email body with your data";
$header = "From: John Doe <john.doe#email.com>";
mail($recipient, $subject, $message, $header);
You can find the documentation here.
I have some php here that works great. I want a mail to be sent to the user who submits a form and I also want a copy of that mail sent to myself but I don't want my email address to be made available to the user.
Here's the php I'm using to govern the mail sending ...
$to = 'xxxx#xxxx.com' . ', ';
$to .= $email;
$subject = 'xxxx';
$message = "Thank you for submitting the form.";
$headers = "From: xxxx#xxxx.com\r\nReply-To: xxxx#xxxx.com";
$mail_sent = #mail( $to, $subject, $message, $headers );
echo $mail_sent ? "Mail sent" : "Mail failed";
When the code is parsed emails are duly sent to both the users submitted email ($email) and the address I enter in the first $to variable however the user can see the email address I enter as another recipient when they receive the email. Anyone know how I can get around this? Any help will be much appreciated. Thanks.
Use a BCC header instead of an additional To in your $headers string. It stands for "Blind Carbon Copy", and instructs the mail server to duplicate the mail to extra recipients, but remove that header from the original copy, so the main recipients can't know it was there.
I have a form that people fill out. It sends me an email when they submit. I want the email to show it is from the person sending it. Their email is one of the fields. I want to be able to hit reply to reply to them.
This is the code I am using:
mail($_POST["e_mail"]."myaddress#email.com", $_POST['e-mail']." Interested in Cajun Catering", "Name: ".$_POST['Name'] ."\n"."Address: ".$_POST['address']."\n"."City: ".$_POST['city']."\n"."E-Mail: ".$_POST['e_mail']."\n"."Phone: ". $_POST['phone']."\n"."Time to call: ".$_POST['call']."\n"."Products: ".$_POST['Prod1']." ".$_POST['Prod2']." ".$_POST['Prod3']." ".$_POST['Prod4']." \n"."Type: ".$_POST['type']."\n"."Event Date: ".$_POST['event_date']."\n"."Number of Guests: ".$_POST['Number']."\n"."Comments: ".$_POST['comments'],'From: '.$_POST['e_mail']);
You could try using the -f option with mail():
$to = "youremailaddress#email.com";
$subject = "The subject";
$message = "The message";
$from = "FROM: returnaddress#email.com";
$return = "-freturnaddress#email.com"
mail($to, $subject, $message, $from, $return);
Note that $return contains the same email address as $from, preceded by -f
Im new to this PHP stuff so please excuse my ignorance
Im after having just one input text box in my flash website where a person just enters there email address and at the click of a button it sends an email to me to a pre defined email address with a predefined subject heading and the email address that was entered in the body of the email
Anyone know of any links or can give some help
all the ones i have found want names email subject message and so on
Any help is appreciated
Mark
EDIT
ok I have the following
In flash I have an input text converted to a movieclip called "addy". Inside the movie clip which has the inputbox which has the variable name "emailaddy"
A Button called "email"
The code i Have running when "email" is clicked is
on (release) {
form.loadVariables("email.php", "POST");
}
the email.php script is as follows
<?php
$sendTo = "mark#here.co.uk";
$subject = "Subscribe to Website";
$headers = "From: Website";
$headers .= "<" . $_POST["addy"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["addy"] . "\r\n";
$headers .= "Return-Path: " . $_POST["addy"];
$message = "Please Subscribe me to Website";
mail(recipient, subject, message, other headers);
mail($sendTo, $subject, $message, $headers);
?>
when I click the button nothing happens
what im after is when the button is clicked for and email to be sent in the following format
To: "mark#here.co.uk"
From: email address specified in text field "addy"
Subject: "Subscribe to Website";
body: "Please subscribe me to Website"
Your help is greatly appreciated
mark
The following code might help:
<?php
$user_mail=$_POST["mail"]; //or $user_mail=$_GET["mail"]; Set to your convenience!
$to_mail="abcde#xyz.com"; //Change to your email address
$message="New user's Email: ".$user_mail; //Change to your requirements
$subject="New user registered"; //Change to your preferred subject
$from="registration#yourwebsite.com"; //Change to your website mail id
mail($to_mail,$subject,$message,"From: $from\n");
To know more about the mail function, please see the documentation.
Well in depth you can do like this
<?php
if($_POST){
$userEmail = $_POST0["emailaddy"]; // textbox variable name comes here
$to = 'abc#xyz.com'; //write down here your email
$subject = 'Subscribe to website'; // your subject goes here
$message = 'Please Subscribe me to Website'; // Mail body message
$headers = 'From: ' . $userEmail . "\r\n" .
'Reply-To: ' . $userEmail . "\r\n" .
'Return-Path: ' . $userEmail; //can send x-Mailer also
mail($to, $subject, $message, $headers);
}else{
echo "Invalid Request";
return false;
}
Don't forget to check first $_POST is happened or not. No need to send Return-path instead of this use x-Mailer which sound good for other mail service providers.
To know more about this read documentation here.
If you want to connect to an SMTP server ,like Postfix or gmail there is a neat php library called PhpMailer.
It is well documentated, so you should be good to go by googleing it :)
When somebody send me a message on my websites contact form, I click the reply button to reply.
I then receive a response that the email was not delivered / failed.
Well, its because the gmail email wants to respond to the server email, instead of the email address that was entered into the Contact Form on my website.
Does anybody know how to fix this?
Here is the PHP script for my contact form:
<?php
$mailTo = 'emailaddress#gmail.com';
$name = htmlspecialchars($_POST['cform_name']);
$mailFrom = htmlspecialchars($_POST['cform_email']);
$subject = 'Message from your website';
$message_text = htmlspecialchars($_POST['cform_message']);
$message = 'From: '.$name.'; Email: '.$mailFrom.' ; Message: '.$message_text;
mail($mailTo, $subject, $message);
?>
Use this:
mail($mailTo, $subject, $message, 'Reply-To: '.$mailFrom);