noreply#example.com not working (rackspace) - php

I'm trying to use noreply to send out emails, but it doesn't work - it wont sent anything. I am using this test-file:
<?php
$to = 'myemailhere';
$subject = 'You received an email message!';
$message = 'This is a message in the email body form.';
$headers = 'From: noreply#example.com' . "\r\n" .
'Reply-To: noreply#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
What could be the problem? By the way, I am using rackspacke, if anyone should know about it.
Thanks in advance!

If you're running on a Rackspace cloud server, you will have to configure the server yourself to be able to send mail. The mail() function relies on the OS configuration to handle emailing. If you are on a Rackspace cloud site, you will likely need to contact Rackspace support for help.
Personally I dodge this bullet altogether by using PEAR's SMTP class. This is a full SMTP implementation in PHP and since it does not rely on any outside configuration or module, it is fully portable. It has saved me a LOT of trouble.
http://pear.php.net/package/Mail
http://pear.php.net/package/Net_SMTP
Note: The PEAR site is having some loading issues atm for me. Give it a minute and it should load.

what is exception? use try catch block. Else try this code
$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.";

Related

PHP mail is not working in my web server

I am using first time mail function in php i get a code from online and it implemented to my program but its not working. Can any please help me to correct this ?
<?php
$to = "ganesh.sunraise#gmail.com";
$subject = "This is subject";
$message = "<b>This is HTML message.</b>";
$message .= "<h1>This is headline.</h1>";
$header = "From:lokesh.sunraise111#gmail.com ";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
echo "Message sent successfully...";
}else {
echo "Message could not be sent...";
}
?>
First, please tell, are you getting "Message sent successfully.." message.
There are many reasons for mail is not working:
Your server does not support send mail.
Please try below method:
<?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);
?>
or use:
PHPmailer
You need to setup the email server locally, or you can use 3-rd party email server to send email from your web server. Added the following lines to your php.ini to send email using gmail.
smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=auto
error_logfile=error.log
auth_username=your-gmail-username#gmail.com
auth_password=your-gmail-password
You can use SMTP as the others suggested, and this can be done using the PHPMailer library.
However, there's another suggestion and this is the one that I prefer (because SMTP may contain some problems that you've to search about them and fix them).
The other suggestion is to use a PHP mailling API like SendGrid or Mailgun - (I prefer SendGrid).
Basic SendGrid integration with PHP:
Download SendGrid from here https://github.com/sendgrid/sendgrid-php/releases/download/v6.2.0/sendgrid-php.zip - or follow the installation instructions for another ways for installation.
Unzip the SendGrid-PHP library and upload it to your server.
Use this sample code (edit it for your needs): https://github.com/sendgrid/sendgrid-php#quick-start

PHP send mail through postfix

I have Postfix and SquirrelMail configured on my server. And user called noreply. So, I am logging to SquirrelMail and sending email to some address. Everything works fine, i am receiving email from noreply#mydomain.com. But when I try to send email from php using mail(),
mail ('test#2ether.net', 'Postfix Test', 'A test email');
server tries to send it from address www-data#mydomain.com. How do I configure it to send emails from noreply#mydomain.com?
I would use PEARMail it is designed to counter such issues, (PHP's "mail()" method is all but useless in today's email meta - too many bots used it ) however the actual answer is this:
$to = 'test#2ether.net';
$subject = 'Postfix Test';
$message = 'A test email';
$headers = 'From: noreply#mydomain.com' . "\r\n" .
'Reply-To: noreply#mydomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);

unable to send e-mail using my function

I am facing e-mail sending problem.
e-mail does not send through my e-mail function.
My code is given below:
ini_set("sendmail_from",$_POST['email']);
$to = 'email#gmail.com';
$subject = $_POST['subject'];
$from = $_POST['email'];
$message = $_POST['message'];
$message = wordwrap($message, 70);
mail($to,$subject,$message,$from);
You have to setup your SMTP mail server and mention those details in php.ini before executing your script. For further info, please check http://www.phpeasystep.com/phptu/23.html
In your code you have to set proper header,
you have used $from for header section of mail.
change its value as
$from= 'From: '.$_POST['email']. "\r\n" .
'Reply-To: '.$_POST['email'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
or you can use below solution.
Use PHPMailer API for sending mail. all are inbuilt there.
download complete code form below link
PHPMailer API
goodluck

php can't send email

I have been trying to send a php contact form, but it's not working at all.
my xampp use 8080 port.
I though that I have to change some configuration on php.ini or httpd.conf as well.
Please anybody help me.
Thank you.
this is the script:
<?php
$to = "tiya.vort4#gmail.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse#example.com";
$headers = 'From: '.$from."\r\n".
'Reply-To: '.$from."\r\n" .
'X-Mailer: PHP/' . phpversion();
if(mail($to,$subject,$message,$headers)){
echo "Mail Sent.";
}
You would have to configure the mercury server bundled with xampp to actually deliver/relay the mails.

E-mail function not working on website

I have a contact page uploaded at this site. This URL is working properly, there are no errors or warnings except send mail function is not working.
When I test it in on our testing server it works properly, I can send and receive the mail.
Can you provide any assistance with this please?
$to = $_POST['email'];
$subject = $_POST['subject'];
$headers = 'From: info#mdpharma.se' . "\r\n" . 'Reply-To: info#mdpharma.se' . "\r\n" ;
$message =$_POST['message'];
$message = wordwrap($message, 70, "\r\n");
if($_POST['email']){
mail($to, $subject, $message,null,'-fwebmaster#example.com');
echo "Mail is successfully sent to you";
} else {
echo "Mail is not set to you";
}
you can take help from here http://phpmailer.worxware.com/index.php?pg=exampledb .
everything is well explained in here. best of luck.

Categories