PHP Contact Form Problem - php

http://www.raymondselda.com/php-contact-form-with-jquery-validation/
I'm trying a few different contact forms including the one above.
I have it running on this page: http://themeforward.com/demo2/features/contact-form/
The problem is this form does not successfully send e-mails to the address in the code (finished code can be found here: http://www.raymondselda.com/php-contact-form-with-jquery-validation/ )
Does anybody know what the problem may be?
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = 'youremail#email.com'; //Put your own email address here
$body = "Name: $name \n\nEmail: $email \n\nSubject: $subject \n\nComments:\n $comments";
$headers = 'From: My Site <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
mail($emailTo, $subject, $body, $headers);
$emailSent = true;

Many reasons:
Mail isn't configured properly on your server. mail() will return a boolean FALSE if it can't hand off the email to an SMTP server. You're not checking for that condition
The SMTP server isn't configured properly to allow you to send through it
The receiver server has your sending server blacklisted
The email is treated as spam and is getting trashed
First place to start looking is mail()'s return value. Then go look at your SMTP server's log to see what happens to the email (if) once PHP handed it over. The SMTP server's log will also say if the receiving server bounced/refused it.
If it's getting silently thrown in a spam folder on the receiver server, there'll be NO evidence of this on your end, and you'll have to investigate further on the receiving end.
Email is a complicated business with many many invididual steps where each one has to work right. Any glitches anywhere along the line and the email is probably gone. You have to investigate what happens at EACH of these stages to figure out why something isn't being delivered.

Related

php domain mail receiving issue

I am using php mail function its working fine for gmail but when i send it to domain email it show me successful message but not receive on my domain email side where i am wrong. my code is below
<?php
$to=$_POST['to'];
$from=abc#gmail.com;
$name="abc";
$subject=$_POST['subject'];
$message=$_POST['message'];
$headers = 'From:'. $name ."\r\n" .
'Reply-To:'. $from . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers,"-f".$from);
echo "Message sent! <a href='mail.php'>Click here</a> to send another email.";
?>
my domain email is contact#automailer.netai.net how can i fix this issue,
There are two completely different processes involved:
Queueing the mail to your local MTA (This is what PHP's mail() does)
This MTA delivering (with possible hops in between) to the final MTA, which delivers into the users mailbox
Obviously PHP only knows about the first step and may be right to consider it successfully done even if something else later goes wrong - e.g. the receiver domain simply not accepting your mail (which sadly is the new normal).
most likely automailer.netai.net is blacklisted and that's why you aren't getting emails.
try using phpMailer library which is free or popular smtp api that offer free trial as long yo don't pass 10,000 emails per month from
sendgrid.com,
maildrill, etc

MY SMTP mail keeps coming through as Junk

I know this is plastered all over the net... But i've tried a lot of solutions and it just wont seem to work. My SMTP mail first came through as junk, and now just comes into my inbox, but with a warning notice saying the email didnt pass the fraud tests..
So im using Optus's SMTP server (mail.optusnet.com.au), and for the "sendmail_from" i have my email address..
for the actual mail, i have this:
$message = 'Hello, $user;
$to = 'nobody#example.com';
$subject = 'Welcome';
$headers = 'From: myemail#hotmail.com' . "\r\n" .
'Reply-To: myemail#hotmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail('myemail#hotmail.com', $subject, $message, $headers);
Any ideas guys?
Thanks,
Adam
Most of E-Mail providers check every received email to decide whether it's a spam or not. For example , if you send an email as myemail#hotmail.com from mail.optusnet.com.au , it will not pass the test and will be put under junk category. In my experience, Yahoo! and Hotmail usually put every email with X-Mailer: PHP header as junk!
For more information take a look at Sender Policy Framework.
About comment:
If you take a look at your received email, you will see something like this:
Received-SPF: neutral (google.com: x.x.x.x is neither permitted nor denied by best guess record for domain of email#mail.optusnet.com.au) client-ip=x.x.x.x;
it tells client that this email at least is NOT trying to show itself as someone else, so it goes to your inbox. but If you use something#hotmail.com, since hotmail.com has a valid IP and it's different from mail.optusnet.com.au, so it goes to your junk folder.

Can't figure out why SMTP email does not work to the same domain it's sending from

I have a PHP customer input form which sends out SMTP mail to the company hosting the form. For some reason the emails are not reaching the recipient's email. If I substitute in any other email address not on the domain it works out fine. I can also list multiple addresses on the To: line and the others will get the email but not the desired info# email address. I cannot change the sending domain since my web hosting won't send mail when they are mismatched. I thought that it might have to do with the sending email address and receiving being the same so I changed the From: address to "onlineform#" instead of "info#" but that made no difference.
I'm perplexed as to what's happening here. I can send email directly from any other account to the "info#" email address and that works fine. I've asked them to check their client and server junk mail folders and they are both clean. Any ideas on what's going on or how to further diagnose the issue? I've simplified the code down to the relevant parts below and the snippet code does the same thing.
<?php
$email_to = "info#domain.tld";
$email_subject = "Subject line here";
$email_message = "Email body here.";
$headers = 'From: onlineform#domain.tld'."\r\n".
'Reply-To: noreply#domain.tld'."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
It could have something to do to the server's mail policy. You may be telling the server that the message is being sent from whatever#domain.tld, but you are not proving it.
Have you tried to send using SMTP authentication? Not sure this is actually the real problem, but it worth testing.
Also, I recommend you to always use mail solutions instead of using the plain php mail() function. I've used PHP Mailer for a long time and not only it works fine, it always eased the boring process of sending e-mails through php.

PHPs mail function doesn't send email to some servers

I have the following code which works on some servers and does not work on others:
$Name = "myname"; //senders name
$email_sender = "myemail.dia#gmail.com"; //senders e-mail adress
$recipient = $email; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email_sender . ">\r\n";
$status = mail($recipient, $subject, $mail_body, $header);
print('ENVOI '. $status);
The $status variable is true but I don't see any email.
$status being true doesn't mean the mail was RECEIVED by your recipient. It just means the mail function successfully delivered the mail to the LOCAL delivery agent. After that it's out of PHP's hands.
The process looks something like this:
PHP script calls mail()
mail() delivers message to the local mail server (sendmail, postfix, exim, etc..)
mail(), having successfully completed 'delivery' of the email, returns TRUE
local mail server connect's to recipient's mail server, delivers mail
recipient's mail server does whatever it has to to get the email into the recipient's inbox.
Since mail() is returning true, that means that at least your sending code is correct enough to not cause things to blow up at that stage. That leaves delivery problems between your and the recipients' mail servers:
a) Perhaps the recipient is using greylisting (in which case the mail SHOULD eventually show up). Maybe your server gives up before the greylist timeout period expires, so the retry attempt(s) is never made.
b) your mail server is blacklisted. Your server, and/or some other potential spam source is in the same netblock have been added to one or more anti-spam RBL lists the recipient subscribes to.
c) Perhaps the remote server is very prickly about header correctness and your server's a bit too relaxed about one or more headers.
At least these problems SHOULD be visible in your own mail server's maillog (generally /var/log/maillog on most Unix-ish systems). Try sending a test mail while watching the log to see how the message procedes through the system. Also check the server's outgoing mail queue (mailq command, usually). Maybe the missing messages are stuck in there.
And then there's the bigger problems:
d) the remote mail server is accepting the message, but silently tossing it because it's flagged as spam or as infected. This you can't detect from your own mail logs, as this is done purely on the recipient end. All you'll see is the "250 OK" success message.
For this you'll need the recipient's help in diagnosing the problem.
This may or may not be related but you have a pretty simple header, I would replace your header variable with something like what's below and see if that changes anything for you.
$headers = 'From: ' .$email_sender. "\r\n" .
'Reply-To: ' .$email_sender. "\r\n" .
'X-Mailer: PHP/' . phpversion();
Make sure you smtp setting are correct on the servers in question.

PHP mail not showing up at Gmail but shows up at Hotmail and other 3rd party/ISP account

I have 2 sites where mail is sent to two vanity gmail accounts. I'm using PHP to handle the mail, but the mail is not showing up at gmail (not in spam/junk, it just doesn't show up). If I switch the PHP to send to my personal hotmail account, the mail shows up. Same for a personal email account through my ISP.
The mail used to show up at those 2 vanity gmail accounts, any ideas why they would just stop?
There is a possibility you did not set proper header data, and those emails are blocked even before reaching spam folder.
Try adding something like this:
$headers = 'From: your#email.com' . "\r\n" .
'Reply-To: some#email.com';
This is the fourth parameter of mail() function.
I have encountered problems in the past where certain free email providers would not receive any email from my servers.
I found that a few things can be the culprit, on top of putting the correct headers in the actual message:
Make sure your server is configured for reverse dns lookup
Make sure you are not running an open smtp relay
Make sure your server did not wind up in any email blacklists (if you had an open relay, you probably got blacklisted.
Chances are, PHP is sending the email just fine, but the Google servers are rejecting any messages coming from your server.
You can test this by doing a quick:
mail -s Test you#gmail.com < /dev/null
If your server is okay, you will receive a message in your gmail, if you don't, PHP isn't the problem.
I've found having a proper SPF record for your domain really helps
http://www.openspf.org/SPF_Record_Syntax
Seems more likely that this is a server configuration issue and not a PHP issue.
As a side note I've found gmail more tolerant than our local system, so I've been able to get messages out to my gmail account, but not my account on the hosting domain.
I don't think Google uses third-party black lists, but they do care about server configuration (does it identify itself correctly, have matching SPF and RDNS records, respond to commands properly). You might try a couple of testing services like this or this.
I see it is too late but ... following code is working for gmail.
<html>
Mail Responder:<br><br>
<?php
$to = $_REQUEST['MyEmail'] ;
$subject = $_REQUEST['subject'] ;
$greeting = $_REQUEST['greeting'] ;
$realname = $_REQUEST['realname'] ;
$HisEmail = $_REQUEST['HisEmail'] ;
$message = $_REQUEST['message'] ;
$headers = 'From: '.$HisEmail;
//$headers = 'From: $HisEmail' . "\r\n" .
//'Reply-To: some#email.com';
$send = mail($to, $subject, $greeting."\n"."\n".$realname."\n"."\n".$HisEmail."\n"."\n".$message, $headers );
if ($send)
$mailReturns = "Mail sent successfully.";
else
$mailReturns = "Mail sent failed.";
?>
<?php echo $mailReturns; ?>
</html>

Categories