i am not able to send mail using php via localhost [duplicate] - php

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

Related

wp_mail unable to send emails [duplicate]

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.

mail not sent form xampp in MAC Book pro [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 6 years ago.
I have this code to send email using smtp, and i got output- Mail sent successfully with following code
ini_set('SMTP', 'mail.veshraj.com.np');
ini_set('smtp_port', 465);
$message = "Hi \n How are you.";
if(mail('veshraj.joshi1#gmail.com', 'Testing Subject for mail function', $message))
{
echo 'Mail sent successfully';
}
But I did not receive any email, this code is in local machine; If smtp not supported in localhost - then how did frameworks like laravel,yii to do so
You are right that you can't send mail on your local host with XAMMP. You need to work on a server that can send mail such as an EC2 instance. Check out: https://laravel.com/docs/5.0/mail and read about how they configure their mail.
They give information how how to send emails to logs instead of recipients as well.

sending mail from localhost without gmail is it possible? [duplicate]

This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 7 years ago.
I want to send emails using php mail() function using xampp on ubuntu. But its not sent. Please check my code. Do I need to set any email server like gmail for it or I can do it without gmail?
<?php
$address = "kthakkar#argusoft.com";
$subject = 'Test email';
$body = 'If you can read this, your email is working.';
echo "Attempting to email $address...<br />";
if (mail($address, $subject, $body)) {
echo 'SUCCESS! PHP successfully delivered email to your MTA. If you don\'t see the email in your inbox in a few minutes, there is a problem with your MTA.';
} else {
echo 'ERROR! PHP could not deliver email to your MTA. Check that your PHP settings are correct for your MTA and your MTA will deliver email.';
}
?>
If I use smtp gmail account, its sending mails but not using php mail() as I dont want to share my gmail credentials.
try this:
How to configure XAMPP to send mail from localhost?
You can use other mail services, not only gmail. Later, when you have your own server, install your mail server :)

How Can I Send Mail From localhost [duplicate]

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

Mails from PHP on XAMPP not being sent

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");

Categories