I am trying to send an email to user once he signs up on my localhost project, I am working on Xampp and my OS is Mac, I know this function is correct:
$to_email = "receipient#gmail.com";
$subject = "Simple Email Test via PHP";
$body = "Hi,nn This is test email send by PHP Script";
$headers = "From: sender\'s email";
if (mail($to_email, $subject, $body, $headers)) {
echo "Email successfully sent to $to_email...";
} else {
echo "Email sending failed...";
}
But there is something to configure in SMTP i guess? however I can't find what and where to edit on MAC, thank you in advance.
If you want to send a mail from a local server using for example XAMPP, you will need to use the mail server in order to do it.
Do something like this:
<?php
ini_set("SMTP", "aspmx.l.google.com");
ini_set("sendmail_from", "YOURMAIL#gmail.com");
$message = "The mail message was sent with the following mail setting:\r\nSMTP = aspmx.l.google.com\r\nsmtp_port = 25\r\nsendmail_from = YourMail#address.com";
$headers = "From: YOURMAIL#gmail.com";
mail("Sending#provider.com", "Testing", $message, $headers);
You will most likely need the mail account's credentials in order to send a mail.
Also, check out Sending email with PHP from an SMTP server.
Related
I have a few questions regarding sending email in PHP. I've been on google for the last few days and I'm still having trouble getting this to fully work.
My first question is how do I change the "From" section of my email? I have "To: support#mydomain.com" in my "from" section:
I'd like to have just the proper name of my domain (eg: "testingstuff.com" -> "Testing Stuff"). How could I achieve this?
Once I actually open the email everything in it is fine and correct, including the From email address being "support#mydomain.com".
Also my mail won't send to gmail addresses. It shows up in my mail queue and my logs say it is sent but it never is received on my gmail. Do I have to take extra steps for Google to accept my email? If so what are those? Do other major mail provides require the same steps, or are they different steps?
This is my code so far:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set("sendmail_from", "support#mydomain.com");
class email {
public static function send($to, $subject, $message) {
$headers = "From: Testing Stuff <support#mydomaincom>\r\n";
$headers .= "Reply-To: support#mydomain.com\r\n";
$headers .= "Content-type: text/html\r\n";
mail($to, $subject, $message, $headers);
}
}
?>
Usage:
require_once("../mail.php");
email::send("support#mydomaincom", "testing email subject", "testing email body");
Am I doing anything wrong in my code?
You need to check if the email is sent properly checking the mail() result, in this way:
$result = mail($to, $subject, $message, $headers);
if(!$result) {
echo "Error";
} else {
echo "Success";
}
this is inside your static function,
Also check your spam folder if the mail function return "success".
I have static ip on my home computer.
I am using windows-7 with xampp .
I creat the code for sending mail
<?php
$to = "someone#example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = "From:" . $from;
mail( $to, $subject, $message, $headers );
echo "Mail Sent.";
?>
but sir mail is not received at destination.
I thinks is it possible to send mail from my home computer using windows7 xampp??
plz answer
See your answer here http://www.c-sharpcorner.com/UploadFile/c8aa13/send-mail-on-local-host-via-mercury-with-xampp/
Or here https://www.google.ru/search?q=use+mercury+to+send+email
I have Plesk with a Network Solutions virtual server. When my site sends out emails using PHP, the email header indicates that the message is coming from an address like this one:
anonymous#002a1c9.netsolvps.com
How do I change this address?
Using the PHP mail() command, you can set the envelope from address using the -f command, and you can include the from address in the message headers as well, like so:
$to = "to#to.com";
$from = "from#from.com";
$subject = "subject";
$message = "this is the message body";
$headers = "From: $from";
$ok = #mail($to, $subject, $message, $headers, "-f " . $from);
Hi I was trying to send Email using php in xammp
I have already started Mercury Service
Heres my code
<?php
$to = "nikhil08514#gmail.com";
$subject = "Hi!";
$body="test";
$headers = "From: root#localhost.com";
if (mail($to, $subject, $body, $headers))
{
echo "Message successfully sent!";
}
else
{
echo "Message delivery failed...";
}
?>
when i execute code i am getting output as
Message successfully sent!
But when i check my mail box.I dont see mail.I checked all folders in my Mailbox but its not present
your code is right try that on server it will work surely, xampp does not send directly like that from xammp. by using smtp you can send.
I'm trying to send an email using PHP code, I'm sure the code is right but I'm not receiving any emails. Can anyone see a problem with this code:
<?php
$to = 'i7906890#bournemouth.ac.uk';
$subject = 'Registration Complete';
$message = 'Thank you for joining us at Arsenic & Vice';
$header = 'From: admin#arsenicandvice.co.uk';
if (mail($to, $subject, $message, $header)){
echo('<p>Sent</p>');
} else {
echo('<p>Fail</p>');
}
?>
I've tested your code on my server and it works fine, I've received the e-mail.
I've also run it so you can receive it on i7906890#...
The problem is on your hosting. Either your e-mail server (qmail...) has a long queue or it is stuck. Contact your server admin.