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.
Related
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.
I have tried every single way on the internet but non of those solve my problem. I'm using WAMP 2.2
I'm using a form to require nyu student email and when the student submit the form it will send to another nyu.edu email and receive a confirmation.
original code:
// send the notification email
$mailto = $EMAIL;//requied from the form
$subject = "Thank you for your nomination!";
$body =
"Dear ".$NAME.",
This confirms that we have received your nomination of ".$NOMINEE." for a teaching award. Thank you for your submission.
NYU Teaching Awards Team";
$headers = "From: somemail#example.com\n\n";
if (mail($mailto, $subject, $body, $headers)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
//end notification email
// send the notification email
$mail_to = "somemail#example.com";
$email_subject = "New Teaching Award Nomination";
$email_body =
"A new teaching award nomination has been submitted by ".$NAME." nominating ".$NOMINEE.".";
$email_headers = "From: somemail#example.com\n\n";
if (mail($mail_to, $email_subject, $email_body, $email_headers)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
//end notification email
the error msg is Failed to connect to mailserver at "localhost" port 25, verify your "SMTP"
so then I tied to put
ini_set("SMTP","nyu.smtp.edu");
ini_set("smtp_port","587");
but it shows: Failed to connect to mailserver at "nyu.smtp.edu" port 587, verify your "SMTP"
I don't know what to do!! please help
"nyu.smtp.edu" doesn't look right. Try "smtp.nyu.edu". You might go back to using port 25.
Be sure that sendmail is installed on your server.
But you have to consider PEAR if you want more options in sending mails.
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.
Problem began with Magento not sending mails, and while debugging I came to this:
when using PHP mail function, it fails if $to contains Name.
<?php
$to = '<myname#gmail.com>'; //Works fine
$to = 'myname#gmail.com'; //Works fine
$to = 'Myname <myname#gmail.com>'; // This doesn't work! No mail and getting "delivery failed";
$subject = "Test";
$body = "How are you?";
if (mail($to, $subject, $body)) {
echo("Message successfully sent!");
} else {
echo("Message delivery failed...");
}
?>
This is a hosted account, so I don't have access to sendmail or any other configs.
Haven't found solutions to this specific problem, but found Magento plugin, which uses SMTP/Google Mail/Apps . Working fine, sending mails.
http://www.magentocommerce.com/magento-connect/aschroder-com-smtp-pro-email-free-and-easy-magento-emailing-for-smtp-gmail-or-google-apps-email.html
I encounter a very strange problem with ixwebhosting.
I am able to send email using the php mail() function with $subject = "test";
But if $subject = "testing of information send"; then i won't be able to receive any email
But actually "Mail sent!" was displayed in the php page.
if (!mail($email, $subject, $body, $from)) { echo "Error Sending Email!"; }
else
{ echo "Mail sent!"; }
Is it possible that the email is being classed as spam somewhere down the track? Are you able to get logs from the mailserver indicating whether mail gets sent?