PHP won't send email with IP in it - php

So I'm sending email with confirmation link or link to change password. I had my website on one IP and now moved it to another IP. And now when I have in my link IP address same as where website is it won't send email, but if there is another IP it will. And on previouse IP address it worked fine.
I don't get it how can ip in mail affect sending actual mail.
Example of my code:
$subject="Pozabljeno geslo";
$message = '
Za spremembo geslo, kliknite na spodnjo povezavo:
http://xyz.x.xyz.3/~blabla/project2/index.php?stran=spremeniGeslo&email='.$email.'&hash='.$hash.'
';
$to = "$email";
$headers = "From: webmaster#example.com" . "\r\n" .
"Reply-To: " .$email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to,$subject,$message,$headers);

Related

php email doesn't send from specified From: address

When I run this script to send an email, the email is being sent from serveradmin#myhosting. They say that the script isn't configured correctly.
I've changed the domain names and info shown below before posting here.
Is there really a problem with the scrip? The email sends, everything is fine.
It takes a bit long...don't know why, the only problem is it doesn't send from the domain I specified.
$to = $_POST['fes-email'];
$subject = 'TEST';
$body = 'TEST TEST';
$headers = 'From: NAME \(Info\) <name#domain.tld>' . "\r\n" .
'Reply-To: name#domain.tld' . "\r\n" .
'Return-Path: name#domain.tld' . "\r\n" .
'X-Priority: 1' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
mail($to, $subject, $body, $headers);
Try using quotes instead of escaping the parentheses:
$headers = 'From: "NAME (Info)" <name#domain.tld>' . "\r\n" .
You should remove the Return-path: header. This header is always recreated by the receiving server, using the envelope information sent via SMTP.
Have you tried putting just <name#domain.tld> in the headers for From?

How to remove root user from php mail from address

I'm implementing a reporting mail in php. I'm using simple php mail function with header information as below:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Daily Report <info#mydomain.com>' . "\r\n".
'Reply-To: info#mydomain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "Report for Domain on ".date('Y-m-d');
$message = "Hello World Testing this mail function.";
$to = "alauddin.xxx#xxx.com";
if(!mail($to, $subject, $message, $headers))
{
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent at ".date("Y-m-d H:i");
}
Mail is working fine (I'm receiving this email) but the problem is that From Address is coming weird like:
On gmail:
Daily Report <info#mydomain.com> via mailgun.org
On outlook:
info=mydomain.com#mailgun.org on behalf of Daily Report <info#mydomain.com>
I think from address is coming with root user address
but I'm looking like:
Dail Report <info#mydomain.com>
Please guys help me. I've already spent almost 6 hours to resolve this over the internet... :(
Mailgun is an e-mail service. The reason why mailgun.org keeps showing up in your e-mail header is because your domain isn't verified.
Verify Domain Info/Instructions

PHP: Gmail ignoring any email I send it via mail()

When using the below code I am able to send (and receive) email to my Yahoo account, but when sending to my Gmail account, nothing shows up
(and yes, I have monitored the Spam folder for over 4hrs - nothing!).
public function sendEmail($email_addy, $temp_pass)
{
$website_name = $this->website_name;
$message = <<<MESSAGE
Greetings!
Your password is:
$temp_pass
Your friends at: $website_name !
MESSAGE;
$headers = 'From: ' . $this->email_from . "\r\n" . 'Reply-To: ' . $this->email_from . "\r\n" . 'X-Mailer: PHP/' . phpversion ();
mail ( $email_addy, $this->email_subject, $message, $headers );
}
Any ideas why Gmail just deletes the email? I thought that the message body text might be too small so I even added to the message with no different results...

Mail, can't send to same email

For some odd reason if a user tries to send an email to themselves, the success function gets ran but the user never receives an email.
If $toAddress and $fromAddress are the same, user never receives the email. If they're different user does.
Have read a few questions on here, saying that if the email is on the same domain as the server it gets blocked for spam. But the users email isn't on the same domain as the server? Was testing this with my gmail account. Reply-to is not the email I'm actually using, it's just dumby text.
$to = $toAddress;
$subject = 'This is an email';
$message = $message;
$headers = 'From: '. $fromAddress . "\r\n" .
'Reply-To:do-not-reply#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html; charset=UTF-8';
if(mail($to, $subject, $message, $headers)){
echo '{"status": "success", "senderAddress": "' . $_SERVER['REMOTE_ADDR'] . '", "content": "' . $_POST['toAddress'] . '"}';
} else {
echo '{"status": "fail", "toAddress": ' . $toAddress . '", "fromAddress": "' . $fromAddress . '"}';
}
Exclude the headers in the mail() function and try it. The headers are triggering GMail's filtering system. If a mail is sent from Gmail, there is a certain Domain-Key based authentication that verifies the identity of the senders.
you might need to Create a TXT DNS record containing this text:
v=spf1 include:_spf.google.com ~all
in your DNS server, to authorize your domain sending email.
Due to filtering systems withing Gmail and Hotmail, when using yourself as the receiver and the from it was going directly into spam within Gmail and Hotmail. With Gmail if the two values are different it would go into your inbox while hotmail will still count it as spam.

PHP Mailing Code sending mail to spam/quarantine

The title explains itself. It is a website for in-house employees to buy and sell from each other. Its based solely around Microsoft Outlook emailing addresses. All the emails are supposed to be sent from the seller's email as they post items. Except when I enter <php phpinfo(); ?> on the action php page it tells me that the sendmail_from attribute thing is sending from a bogus email on the server. It seems to be the automatic email for the php script to send from. This may be why the emails are getting sent to spam, because the email is not valid. Also, I read online about having full and valid headers but most headers seem optional and i cant find anywhere that explains optimal headers. My mailing code:
//send approval email to the approver
$from = isset($_POST['from'])? $_POST['from']:1;
$message = isset($_POST['message'])? $_POST['message']:1;
$message = $message . '<a href="http://dev-corkboard/newapproval.php?id='
.$result[0][0].'"> Click here to approve website post.</a>';
// In case any of our lines are larger than 70 characters, we should use
// wordwrap()
$message = wordwrap($message, 70);
$to = 'clehane#eatonvance.com';
$replyto = isset($_POST['replyto'])? $_POST['replyto']:1;
$subject = isset($_POST['subject'])? $_POST['subject']:1;
$headers = "MIME-Version: 1.0" . "\r\n" . 'From: "'.$from.'"' . "\r\n" .
'Reply-To: "'.$replyto.'"' . "\r\n" .
'Content-Type:text/html;charset=iso-8859-1' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
//test message for email
}
header ("location: newindex.php"); `
Any ideas?
And bam! Solved it, needed to put email addresses as such:
$from = 'MyName <myemail#mycompany.com>';
And I also included these headers:
"X-Priority: 0\r\n".
"X-MSMail-Priority: Normal\r\n".
"X-Mailer: mycompany.com

Categories