PHPMailer: Can't send email to any kind of domain - php

I am new to PHPMailer. I am able to send emails to email addresses like abc#gmail.com. But I can't send any email to email addresses like myemail#office.com or myemail#officename.net. PHPMailer does not show any kind of error but it is not sending my email.Here is my phpMailer setup:
require_once('PHPMailer-master/class.phpmailer.php');
$email = new PHPMailer();
$email->From = "info#mydomain.com";
$email->FromName = "Any Name";
$email->AddAddress("enam#domain.com");
$email->AddAddress("enam#domainn.net");
$email->isHTML(true);
$email->Subject = 'Order Confirmation';
$email->Body = "Hello. I am testing <b>PHP Mailer.</b>";
$email->Send();
Can anyone say how can i send email to email addresses of any kind of domain?

Related

Gsuite email with phpmailer not sending email to live email address

I have setup gsuite email and want to use it for emails that my website sends when someone registers etc. I have setup phpmailer to do that.
$email = new PHPMailer();
$email->Host = "stmp.gmail.com";
$email->SMTPDebug = 2;
$email->SMTPAuth = true;
$email->SMTPSecure = "ssl";
$email->Port = 465;
$email->Username = "myemail#mydomain.com";
$email->Password = "password";
$email->AddReplyTo('myemail#mydomain.com', "My Email");
$email->SetFrom('myemail#mydomain.com', "My Email");
$email->AddAddress("email#gmail.com");
$email->AddAddress("email#live.com");
$email->Subject = "test email";
$email->MsgHTML("<a>This is test</a>");
$email->Send();
I have tried to change subject/content of the email, also tried tls/587 but it sends email to gmail but not to live which I think I don't want to miss out.
Turns out my ip was listed in spamhaus, which they cleared after I contacted them. Now I receive emails on live.com as well.

PHPMailer ismail not working in bluehost

I am usng bluehost as server of my domain. I am using below code for sending mail using PHPMailer. The code does not through error and confirms that the mail has gone. But actually the mail does not go to recipient. can anyone suggest what is wrong here?
$Recpnt1='abc#gmail.com';
$emailfrom = 'xyz#AlphaBeta.com';
require_once 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer;
//From email address and name
$mail->From = $emailfrom;
$mail->FromName = "AlphaBeta";
//To address and name
$mail->addAddress($Recpnt1);
//Send HTML or Plain Text email
$mail->isHTML(true);
// Your subject
$mail->Subject = "Your confirmation link here";
$message='ABCD';
$mail->Body = $message;
if($mail->send())
{
$error = $error . "Confirmation link Has Been Sent To Your Email Address.";
}
else
{
$error = $error . 'Cannot send Confirmation link to your e-mail address';
}

i am submitting my form with php but it is going to spam

**> the mail posted with the below given is going to spam. I am not using
captcha in the form as i don want to. So can anybody help me to the
mail in Inbox**
<?php
if(isset($_POST['submit']))
{
$name = $_POST['Name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$date = $_POST['checkinDate'];
$package = $_POST['package'];
$person = $_POST['adults'];
$kids = $_POST['kids'];
$ip=$_SERVER['REMOTE_ADDR']; //trace the ip address of the user submited
$subject ="Query From :Kerala-Honeymoon-Packages - Promotion\n"; //subject of the email
$to="paul#roverholidays.com";
$cc="online#roverholidays.com";
$ccc="deepti#roverholidays.com";
$from=$_POST['email'];
$adc="Name :$name\n";
$adc.="Email :$email\n";
$adc.="Phone :$phone\n";
$adc.="Date of Travel :$date\n";
$adc.="Package :$package\n";
$adc.="Adults :$person\n";
$adc.="Kids :$kids\n";
$message ="$name copy of the query you submited in Kerala-Honeymoon-Packages";//message header to user submited
$headers="From: <".$from. ">" ;
mail($cc,$subject,$adc,$headers);
mail($ccc,$subject,$adc,$headers);
mail($email,$message,$adc);
header("Location: thanks.htm");
}
else
{
return false;
}
?>
coding-wise I don't think there is anything you can do because it is the email server that classifies your email as a spam not the way you coded your script. All you can do is to control it from the receiver email setting i.e you setup your gmail filters to detect that email based on keyword like "Kerala-Honeymoon-Packages" and move it out of spam.
I don't know for sure what the email servers algorithms are for marking email as spam. However, I think sending email from different domain rather than your domain name is likely to be detected as phishing email. what I mean is when someone put his/her yahoo email in the form and click on send, your server will send the email to emails addresses in the script but it will send it as if it came from yahoo, which will be suspicious for the receiver email server as it knows that it did not come from yahoo.
Many email services block mail sent directly from random servers because they have little to no reputation as a legitimate source of non-spam emails. Instead of using the straight php mail() function, try using a SMTP service like Mandrill or Gmail's SMTP service. Both are free.
Here is the configuration page for Mandrill:
http://help.mandrill.com/entries/23737696-How-do-I-send-with-PHPMailer-
<?php
require 'class.phpmailer.php';
$mail = new PHPMailer;
$mail->IsSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server
$mail->Port = 587; // Set the SMTP port
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'MANDRILL_USERNAME'; // SMTP username
$mail->Password = 'MANDRILL_APIKEY'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
$mail->From = 'from#example.com';
$mail->FromName = 'Your From name';
$mail->AddAddress('josh#example.net', 'Josh Adams'); // Add a recipient
$mail->AddAddress('ellen#example.com'); // Name is optional
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <strong>in bold!</strong>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';

phpgmailer set from mail issue

I'm trying to use php mail class as shown in the example.
http://www.vulgarisoip.com/category/phpgmailer/
I'm using it my site's contact us form. Can I set the "$mail->From" address as the person who filled the form? When i reveive the mail it always shows that the "from address" as my gmail account. Any help would really helpful.
<?php
require_once('phpgmailer/class.phpgmailer.php');
$mail = new PHPGMailer();
$mail->Username = 'username#gmail.com';
$mail->Password = 'gmailpassword';
$mail->From = 'from#hotmail.com'; // Like to set this address as the address of the person who filled the form
$mail->FromName = 'User Name';
$mail->Subject = 'Subject';
$mail->AddAddress('myname#mydomain.com'); // To which address the mail to be delivered
$mail->Body = 'Hey buddy, heres an email!';
$mail->Send();
?>
$mail->From = $_POST['from'];
or what ever the field is named
Gmail uses the authenticated account as the sender to cut down on address spoofing and spam. No matter what you set as the from address, Gmail will auto set it to your gmail user.
UPDATE
Your comment:
"My intention was actually when I received a mail with the actual
sender as "from address", so that I can directly reply to him."
You may want to try:
$mail->AddReplyTo($email, $display_name);

How to sent notification email to user avoiding to be marked as SPAM by phpgmailer?

I`m using PHPGmailer to sent some important notification for registered user. The email is Google App powered.
here is my configuration for sent email function with PHPGMailer class:
function send_mail($to, $subject, $content)
{
$mail = new PHPGMailer();
$mail->Username = 'info#domain.com';
$mail->Password = 'xxxxxx';
$mail->From = 'info#domain.com';
$mail->FromName = 'domain';
$mail->Subject = $subject;
$mail->CharSet = 'UTF-8';
$mail->AddAddress($to);
$mail->IsHTML(true);
$mail->Body = $content;
$mail->Send();
}
Is it good enough to sent notification and prevent to be marked as spam? Or add some more additional configuration and settings?
A big part of preventing emails from being marked as spam is your mail server setup.
A google search for 'prevent emails from being marked as spam' returns a bunch of info.

Categories