<?php
$to = 'something#gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: example#test.com' . "\r\n" .
'Reply-To: example#test.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
$send = mail($to, $subject, $message, $headers );
if ($send)
$mailReturns = "Mail sent successfully.";
else
$mailReturns = "Mail sent failed.";
?>
<?php echo $mailReturns; ?>
after run it shows mail sent successfully
but mail not showing up in any of the accounts. iv tried gmail, yahoo, rediff and ibibo why????
If you have qmail installed on your server, try using that. Alternatively, there is a nice PHP mailer class called swiftmail that is available here: http://swiftmailer.org/ you can try.
Your emails are probably being junked/marked as spam.
Try to see in spam folder.
Related
What is wrong with my PHP Send Mail function? I am hosting this script on a live server.
$to = 'myemail#gmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: exampleemail#gmail.com' . "\r\n" .
'Reply-To: exampleemail#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to, $subject, $message, $headers)){}
else{
echo "Email sending failed";
}
I keep receiving the "Email sending Failed" message.
On my server I am trying to send an email via PHP but it always just says message not set, even after hardcoding in values and removing the header it still says message not sent. What could the problem be?
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
$recipient = $_POST["recipient"];
$title = $_POST["title"];
$body = $_POST["body"];
$headers = 'From: admin#example.com' . "\r\n" .
'Reply-To: admin#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$sendMail = mail($recipient, $title, $body, $headers);
if( $sendMail == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
I dont see problem with the code. Mostly because your mail server is not configured .
I'm using iPage for my website, and I'm using a simple mail() method to send test mails from my page. On iPage, I have email capabilities via mark#domain.com. But when I send an email out, it comes from the iPage server and is sent from ipg.domain#boscustweb3506.eigbox.net, which is quite ugly looking!
Is there a way I can use the mail() method in php to send an email from my page that will use the shorter sender above? Thanks for any and all help!
you need to add a header named From. this code will send with the mail address webmaster#example.com:
$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);
Try this, You can add the From header to customise the sender address.
$from ='mark#domain.com';
$headers = 'From: ' . $from . "\r\n";
...
mail($to, $subject, $message, $headers);
I am having a problem sending emails when I add header information.
However when I just remove the header parameter it works. What is wrong? Is it the code? Or some setting I need to change on the web server admin panel to say "Allow-Headers" or something?
I am trying to send to hotmail in case this has any relavance in determining the problem.
Any help would be greatly appreciated. Thanks.
Below Doesn't Send Email:
<?php
$to = 'iputmyrealemailhere#hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com';
mail($to, $subject, $message, $headers);
?>
Below Sends Email:
<?php
$to = 'iputmyrealemailhere#hotmail.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com';
mail($to, $subject, $message);
?>
I use these headers in my php mailing function and it works well. Note: I also use a third party mail-routing service to avoid having my mails marked as coming from a spammy IP. You might want to look into that also.
$headers = 'From: '.$from.'#foo.net' . "\r\n" .
'Reply-To: '.$from.'#foo.net' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n";
I also use the optional fifth parameter to mail() to set the envelope address, e.g.:
$parameters = '-f '.$from.'#foo.net';
so the final call is:
mail($to, $subject, $message, $headers, $parameters);
You can just delete the "FROM:" from the headers list .. it prevents it in some hosts .But the real question then will be how ca I change the sent from email address to a specific email that I want
I would like to sent e-mail to registered users with the following code:
$to = $ownerMail;
$subject = 'SGKM - Online Ticket';
$message = 'SGKM - Online Ticket';
$headers = 'From: sgkm#ku.edu.tr' . "\r\n" .
'Reply-To: sgkm#ku.edu.tr' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
but unfortunately, in mail: "from sgkm#ku.edu.tr via venus.nswebhost.com" so, I still see venus.nswebhost.com in sender's mail part. Can't I delete that ?
What should I do ?
Thanks
You need to use the 'additional_parameters' flag in the mail() call to specify an "envelope".
$sent = mail($to, $subject, $message, $headers, "-f webmaster#example.com");
Unless I'm mistaken, you're not using the $headers variable in your mail() function.
From: http://php.net/manual/en/function.mail.php
<?php
$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);
?>
mail($to, $subject, $message, $headers);
You forgot to use the $headers variable you've set up! Try:
$sent = mail($to, $subject, $message, $headers);