php mail function from a adress with åäö? - php

Can you send a mail via php from a emailadress with ÅÄÖ?
Like this:
$to = "$email";
$subject = "Test mail";
$message = "Test";
$from = "info#testwithÅÄÖ.se";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

Related

How to set sender's email send from specific domain only?

For example, i only want the sender's email is from "anything#abc.com", if other email like "anything#cde.com" is not allow, only #abc.com is allowed. How should i do that?
let say $_POST['Sender']="anything#abc.com";
$to = "someone#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = $_POST['Sender'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
you should be able to just wrap it within an if statement:
$to = "someone#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = $_POST['Sender'];
$headers = "From:" . $from;
if ($from === "anything#abc.com") {
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
}
You can use PHP's strstr function to strip the first part of the email off (everything before #) like so:
$from = strstr($_POST["Sender"], "#");
if($from == "#abc.com") {
// send mail
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
}
See http://php.net/manual/en/function.strstr.php for more information on the strstr function

PHP Email Not Work

i have a website wherein you can inquiry or leave questions and comments and send it via email, the code runs perfectly but it doesn't send email. here is my code:
$myemail = 'albertdaracan#gmail.com';//<-----Put Your email address here.
$fname = "albert";
$lname = "daracan";
$subject = "Magosaburo Inquery Form";
$email_address = $_POST['email'];
$message = "Name: ".$fname." ".$lname;
$message = "test";
$to = $myemail;
$email_subject = $subject;
$email_body = $message;
$headers = "From: $fname $lname <$email_address>\n";
$headers .= "Cc: ";
$headers .= "Reply-To: $email_address";
//redirect to the 'thank you' page
if(mail($to,$email_subject,$email_body,$headers)){
echo "mail successful send";
}else{
echo "Could not send you mail, Please try again later";
}
$message2 = "test";
$to2 = $email_address;
$email_subject2 = "Magosaburo";
$email_body2 = "$message2";
$headers2 = "From: Magosaburo <$myemail>\n";
$headers2 .= "Reply-To: $email_address";
//redirect to the 'thank you' page
if(mail($to2,$email_subject2,$email_body2,$headers2)){
echo "mail successful send";
}else{
echo "Could not send you mail, Please try again later";
}
my other works was fine it send email, but it is in other server...
why not try to fix this issue first
$fname = "albert" //missing semi colon
$lname = "daracan" //missing semi colon
$subject = "Magosaburo Inquery Form"; //terminated here
may be the values were not assigned well which causes the faultness

adding some text into message in mail

$contactname = $_POST['contactname'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = 'Ձեզ գրել են ձեր կայքից';
$to = 'stereoshoots#gmail.com';
$headers = "From: ".$email;
mail($to,$sub,$message,$headers);
I got $contactname (client name). My task is the text like this :
From : $contactname
$message (the text that client wrote).
How should i implant name into text?
You can costumise, the below, but from contact name is in this case, $from
<?php
$to = "someone#example.com";
$subject = "Ձեզ գրել են ձեր կայքից";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = "From:" . $from;
if(mail($to,$subject,$message,$headers)){
echo "Mail Sent.";}
else{
echo "Mail not sent";
}
?>

Warning: mail() [function.mail]: SMTP server response: 550 Invalid recipient:

I'm creating a 'forgot password' page where the user enters their email address and the script finds the password associated to that email, and sends it to the stored email address.
I believe the problem has to do with my SMTP Mailserver. I am using WAMP which doesn't have one so I downloaded one that was free.
This is the php script I'm using:
$id = checkEmail($email);
$record = readMemberRecord($id);
$password = #mysql_result($record,0,'cred');
if($password){
$email_subject = "Email Request";
$email_body = "Your password is ".$password.".";
$header = "NinjaMan";
mail($email, $email_subject, $email_body,$header);
$msg = "Your password has been sent to ".$email.".";
}else{
$msg = "Sorry, the email ".$email." wasn't found.";
}
The $msg outputs properly so I know the code is passing the mail function.
Try sending in a proper "From" in $header.
$emailFrom = "admin#yourdomain.com"; // match this to the domain you are sending email from
$email = "example#example.com";
$subject = "Email Request";
$headers = 'From:' . $emailFrom . "\r\n";
$headers .= "Reply-To: " . $email . "\r\n";
$headers .= "Return-path: " . $email;
$message = "Your password is ".$password.".";
mail($email, $subject, $message, $headers);
See details of the mail() function.
If this doesn't work, try using PHPMailer. You configure it in code, no need to edit php.ini.
I've used it in some projects (v 2.0.4, I see the latest is 5.1) and had no problems.
Try using Google's server to send mails, you can see how to do that here
Try using this
//Email information
$to = "garggarima#gmail.com";
$subject = "Test mail";
$message = "Hello! This is a test email message.";
$from = "support#sltechsoft.com";
$headers = "From:" . $from;
$mail=mail($to,$subject,$message,$headers);
if($mail) {
echo "Thanks for mail";
} else {
echo "Mail not Sent";
}
//Email response
echo "Thank you for contacting us!";

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