php mail function sometimes send blank emails - php

I know how to use php mail() function. It works for me. But sometimes I am receiving blank emails with no message body, subject I mentioned in php mailer function with blank email id.
I did javascript validation for each and every form so that no field will be blank while submitting form.
After this validation also I am receiving blank email. Can any one please tell me why this is happening?
Note: I tried to submit form with blank spaces in text boxes but with blank spaces form is not submitting because of javascript validation.
EDIT:
code I used:
<?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);
?>
This is just an example from http://php.net/manual/en/function.mail.php

Without code it will be not possible to check what will be the issue. But below are some advice you can use :
1) Never use javascript validation, as it be bypassed, as it is client side not server side. Always use server side validation.
2) php mail function is good to use, but it is not feature rich. Try using swift or PhpMailer.
Hope this will help.

Using Mandrill email sending is perfect. No blank mails sent using Mandrill...

Related

I needed to make a script that sends emails seen as another person [duplicate]

I have a PHP Contact form on a site I am hosing on our mediatemple grid server that was made with Rapidweaver. It works well except that the email it generates to our info#ourdomain.com is sent as serveradmin#ourdomain.com. I think the server is just using the trash/blackhole address. Any way to adjust my php or better yet, the server settings, to send the mail as the reply-to address that the user fills out on the contact form itself?
Why? Well Google hosts the email for this domain and I wanted to use their canned responses as an auto-responder. The problem of course, is that the auto-response goes to serveradmin#ourdomain.com and not the user's email address that he filled in on the form.
Thank you for the help!
-Hunter
You can add headers to your mail
<?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);
?>
see mail phpdoc

PhP e-mail auto e-mail response

On my website we have a promotion going on where users input their name and e-mail and then we send them an e-mail with the same title, same text and an the voucher image at the end embedded/inserted onto the e-mail (not attached).
We thought we would be able to copy paste easily but over the past 6 weeks we have sent out over 1000 e-mails and this is undo able any more.
We have a php code that simply sends us their info.
Does anyone know what to add at the end of the php so that when someone inputs their e-mail and name we can just automatically send an e-mail to them with the "template" title, text and image?
I have tried many different things but most programmes are newsletter senders not auto-responders. Can't use gmail auto response either because we receive other e-mails for different things as well. We don't want to send the promo to everyone who e-mails us.
Any help?
Cheers.
Check Github for sendemail repository. It allows you to send emails through php. What you can do is that you can set sendemail repository in your project then whenever someone enter an email id run a php script.For configuring sendemail everything is provided on Github.
Link: https://github.com/mogaal/sendemail
Script will look something like this:
$message = "Thank you for your interest. We will get back to you as soon as possible.<br />Sincerely,<br />(My Name)";
$subject = "Confirmation";
$headers2 = "From: $webMaster\r\n";
$headers2 .= "Content-type: text/html\r\n";
mail($leademail, $subject, $message, $headers2);
Here is a sample script you can use without any third party classes.
<?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);
?>
You can add html content to the $message variable

Send multiple emails using PHP

I working on a project in which i need to develop a functionality to send multiple emails to client with one click and i am adding customer id in one text box separating them with comma.
Please tell me how to do this problematically. Your advice
<?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);
?>
if you want to send the user as in db jus replace the $to address from db and place these code in loop.
php.net's mail function page explains this well
to be fair we all had to start somewhere. The problem with using "vanilla PHP mail" is that it is almost always used when people send mail as spam. So for 10 years mail servers haven't liked it. There are ways round it but to be brief:
To send Email via a webpage you "should"
have your mail server resolve RDNS
try to avoid cheap/free web hotels as mailserver hosts
use PHP PEAR MAIL (this is tricky/odd to install)
properly apply the correct headers for the mail in PEAR
Check below link may be help you.
http://www.quackit.com/php/tutorial/php_mail.cfm

How to send email without displaying the hostname of the server in "from" section

Whenever I send an email to my clients, their inbox shows the email details of my server that is hosting my website, instead of the email I mention in the from variable. something like this
From John Smith username704#sadalsuud.hostingService.com
What I want is this
From accounts#myWebsite.com
Help will be appreiated. I am clueless as to whether it is a question more suitable for mentioning in Serverfault. If so, then let me know.
$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);
What Narek says sometimes works, but kind of depends of the settings. I had a simular problem in the past using mail() and whatever i tried, i sometimes just got the hostname. It appeared to be a server(settings) issue.
What did help me, was using Swiftmailer over SMTP ( http://swiftmailer.org/ ) instead. You should give it a try, it's a very nice script.

Email form isn't sending

I have an email form that isn't sending out an email to the recipient or a copy to the client. The form can be found at www.kelcos.co.uk/contact and the files associated with this are:
/index.php
/jquery.js
/sendemail.php
/submitform.php
/thanks.php
/verify.php
I have used this form on other websites http://www.bowlesgreen.co.uk/contact/ and http://www.arbortectreecare.co.uk/contact/ and it works fine - the only difference is that these other sites use my usual hosting provider and for the one that won't send I'm working through the clients hosting provider, which I can only presume is what is causing the problem.
I have contacted the hosting and so far we have eliminated a few things such as:
'The limitation to our systems is that the emails sent using scripts will be blocked if they are not going to or coming from an email address setup on the web hosting account. - so I am now sending the form to an a kelcos.co.uk address, but still no joy.
PHP/ASP was originally disabled, but now has been activated
the mail() script is enabled
I would really appreciated any advise any of you could offer.
Thanks
No, http://www.bowlesgreen.co.uk/contact/ doesn't work fine as you said. Firebug reports: POST http://www.bowlesgreen.co.uk/projects/wp/wp-content/themes/bowlesgreen/contactform/sendemail.php 404 Not Found
Your forms are submitting to the wrong URL.
Is Qmail available on the server? Are you setting the headers properly?
Try something like the following:
putenv ("QMAILUSER=myuser");
putenv ("QMAILNAME=My Name");
putenv ("QMAILHOST=mydomain.com");
$headers = 'From: My Name <myname#mydomain.com>' . "\r\n" .
'Reply-To: My Name <myname#mydomain.com>' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$mail_to = 'myemail#myemail.com';
$subject = "Testing email";
$body = "This mail is a test";
mail($mail_to, $subject, $body, $headers);
And see if you receive an email!
try these
http://forum.codecall.net/php-forum/28696-php-contact-form-isnt-sending-out-email.html
http://www.astahost.com/info.php/Php-Send-Email-Problem_t2259.html

Categories