This question already has answers here:
How to configure XAMPP to send mail from localhost?
(11 answers)
Closed 4 years ago.
I Cant send Mail From Localhost.
I Use Xampp And My php.ini And sendmail.ini File Are Proper Configured
What Can I Do Now?
You cannot send mail from localhost using mail function. you have to use SMTP in order to send email.
Check this for how to use SMTP to send email.
If you only need to test your mail function without being connected to the internet, you should use Papercut, this simple application to test send mail. You don't need to configure anything.
Just run it and try test send mail.
sendmail.php
<?php
$to = "sampleperson#example.com";
$subject = "My Subject";
$txt = "My sample msg.";
$headers = "From: webmaster#example.com" . "\r\n" .
"CC: somebodyelse#example.com";
mail($to,$subject,$txt,$headers);
?>
You will get this.
Papercut Inbox
Download Papercut here
Related
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 4 years ago.
I am creating a login page.For that, after the signup I need to send the mail to the user for verification.Therefore, I need to send mail.To send the mail, I tried with mail() function like this,
<?php
//sending email with the php mail()
mail('mahadev.3333#gmail.com', 'Subject Line Here', 'Body of Message Here', 'From: vidya.5555#gmail.com');
?>
I have configured php.ini file also like below,
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from ="vidya.merahkee#gmail.com"
I am using windows 64-bit.
And also I have tried with phpmailer. But,I didn't find any solution.Since, 2 day I am trying this.I am unable to do this one.
Can anybody help me to solve this?
First of all if you are using the script on production server then ask your admin for the mail function is active or not . Some time on production server it's blocked by Site admin.
Second if you are using this script on localhost server means on your desktop then first you have to use the mail server start.
for example i am considering that you are using XAMMPP on windows then Your have to start the Mercury Mail Server From the XAMPP control panel.
Mercury by default comes with postmaster and newuser two users.
Then You have to download Mozilla Thunderbird mail client and configure the
newuser and postmaster user in mail client by following the Create New account > email using the newuser#localhost and manually configure the pop and smtp server and port . usually default ports.
you can use the sendmail_from ="newuser#localhost"
then check Mercury Mail server is running then test your script.
it will send the mail and you then check it in the Mozilla Thunderbird mail client.
Third : for setting the From: you have to use the header like below
$headers = "From: newuser < newuser#domain.com >\n";
<?php
$send_to = 'postmaster#localhost';
$mail_subject = 'Subject of Your mail';
$message_body = 'Body of your email like message form php script.';
$headers = 'From: newuser#localhost' . "\r\n";
mail($send_to, $mail_subject, $message_body, $headers);
?>
I hope this will solve the problem .
NOTE if you want to send email form localhost to gamil or any other mail site then you have to use the sendmail application or more tutorial Search the google Term like 'Send email via Gmail in PHP '
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
I have a WordPress website installed on my localhost machine and I'm unable to send emails using the function wp_mail. I don't get any error but I can't receive my emails either? Can someone point me on the right direction? Here's an example of my code:
include("wp-mail.php");
$to = 'test#gmail.com';
$subject = 'Hello';
$message = 'Steve';
wp_mail( $to, $subject, $message );
Thanks
wp_mail works similar to PHP's function mail. You can read more about it here. PHP mail function needs access to sendmail binary, as stated in docs, you shouldn't have this configured in localhost, that's why it fails to send emails.
In order to send emails when testing your website in localhost you should configure SMTP to send emails. There's this plugin caled WP Mail SMTP, you can install it here, I use it on most of my WordPress installations and works really grate.
It overides the wp_mail function and enables you to send emails using the Gmail SMTP server, for instance. You can use any SMTP server you want.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
I am using ubuntu with xampp. I need to send mail from localhost . I am new to php.Can u help me what are all i need to configure to send mail from localhost?
<?php
$to = "mymail#gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "othemail#gmail.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers) or die("unable to send");
echo "Mail Sent.";
?>
you should try this link to send mail from localhost
http://www.mittalpatel.co.in/php_send_mail_from_localhost_using_gmail_smtp
which gives you insight about how to send mail from localhost using third party SMTP server.
You should send email using SMTP, it will work.It will work in win32. i am not sure about any other.Check following link.
Send email from localhost running XAMMP in PHP using GMAIL mail server
My mail function is not working. My mail function is as follows:
function sendmail($from,$to,$sub,$msg)
{
$subject=$sub;
$message=$msg;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= "From: <'.$from.'>" . "\r\n";
mail($to,$subject,$message,$headers);
}
This works fine in some of my other project but not working in a new project of mine.
It may be mail not working in your server.
Check with a basic mail function and upload it in your root to test mail.
testmail.php
<?php
$msg = "This is test mail";
mail("tester#email.com","My subject",$msg);
?>
If mail not working then try with authenticated mail like phpmailer, sendmail.
PHP inbuilt mail() function wont work in ur localhost or the server WHICH DOES NOT support smtp server. If you are running this project in ur pc locally then this mail function wont work. you need to upload it in server and then try, it will work!
If you are running this project in server and your mail doesn't fire then possibilities are :
1) You are hosted it in Windows server which supports PHP but not smtp.
2) If server is Linux, then server might have disabled outgoing mail. pls contact your server
I suggest you to use PHPMailer [https://github.com/Synchro/PHPMailer] which sends mail through external SMTP server like GMail,Hotmail etc.. give it a try..
I finally solved the issue. The problem was I had given my gmail id as admin id ( i.e, from address) now i changed it to a mail id from the domain name(say, if the domain name is www.abc.com I gave id as noreply#abc.com) and it works.
And now i came to know that giving gmail or other mail ids will work in some cases in some servers but it wont work on all servers. So using mail id in domain name (noreply#abc.com) will solve this issue. Even though gmail ids works in some servers still it will give a error message in the body of mail or it will be a spam mail so it is better to use mail id derived from domain name like noreply#abc.com.
Thank You....
How to send an mail from the website ..?
I am using html and php for my static website but it is not senting an mail through xamp server.... my php code is
<?php
$to = "my#domain.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "from#domain.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
?>
but it is not sending an email..
can anyone help me..?
It is more likely that you are trying to send mail using your local machine. You could try the following:
Open the php.ini. You should know where it is located because it depends upon the particular server you're running.
Search for the attribute called SMTP in the php.ini file. Generally you can find the line SMTP=localhost. change the localhost to the smtp server name of your ISP. And, there is another attribute called smtp_port which should be set to 25. E.g. in your php.ini file:
SMTP = smtp.mylink.com.np
smtp_port = 25
Restart the apache server so that PHP modules and attributes will be reloaded.
Now try to send the mail using the mail() function
mail("you#yourdomain.com","test subject","test body");