I know this has been asked before, but i wanted to show my case because i tried to solve it with other answers but i coundt solve it.
I m trying to do a Contact form but when i choose the email of the receiver if i choose #hotmail.com or #advancedinstitute.cl they dont receive the email.
I tried to choose another type of email like gmail, yahoo or terra and the email arrives without problem.
I know it must be because the spam policies of those servers but i dont know how to fix it.
This is my code of the phpMailer:
$mail = new PHPMailer();
$mail->Host = "localhost";
$mail->Hostname = "Advanced Institute";
$mail->From = $_POST["email"];
$mail->FromName = $_POST["email"];
$mail->Subject = "Quiero contactarme con Advanced Institute";
$mail->AddAddress("carmeng.advanced#terra.cl","Advanced Institute");
$mail->AddReplyTo($_POST["email"]);
$mail->IsHTML(true); // El correo se envía como HTML
$body = '<html><body><div>Nombre : '.$_POST["nombre"].'<br> Email : '.$_POST["email"].'<br> Telefono : '.$_POST["telefono"].'<br> Asunto : '.$_POST["asunto"].'<br> Comentarios: '.$_POST["comentarios"].'<br> </div></body></html>';
$mail->Body = $body;
if(!$mail->Body) {
echo 'Error: ' . $mail->ErrorInfo;
}else{
$mail->Send();
I hope my english was enough for you guys to understand my problem.
THANK YOU IN ADVANCED
You probably need to set up SPF records for the domain name.
Further information: http://en.wikipedia.org/wiki/Sender_Policy_Framework
Recommended SPF Wizard http://www.kitterman.com/spf/validate.html
Also the from address should be from the sending domain name, not user input.
Related
i got a problem and i cant find any solution.
When customers shop with me on the site, they come to a thank you page. Since we send with phpmailer an email with attachment invoice. The email is however unfortunately sent 3 times and only once with attachment and the correct parameter. The other two mails are naked without price without address without name without attachment.
PHPmail code:
<?php
require_once (JPATH_ROOT.'/PHPMailer/class.phpmailer.php');
require_once (JPATH_ROOT.'/PHPMailer/language/phpmailer.lang-de.php');
$mail = new PHPMailer;
$mail->From = 'info#picknstick.de';
$mail->FromName = 'pickNstick';
$mail->addAddress($arr["email"]);
$mail->addReplyTo('info#picknstick.de');
$mail->addCC('info#picknstick.de');
$mail->isHTML(true); // Mail als HTML versenden
$mail->Subject = 'pickNstick-Rechnung';
$mail->AddAttachment($_SERVER["DOCUMENT_ROOT"].'rechnung/'.$pdfName, 'Rechnung_pickNstick.pdf');
$mail->Body =
'
Hallo <b>'.$arr["nachname"].' '.$arr["name"].'</b>,
<hr>
';
if(!$mail->send()) {
echo 'Mail wurde nicht abgesendet';
echo 'Fehlermeldung: ' . $mail->ErrorInfo;
} else {
echo 'Rechnung wurder per Email nochmals an Sie verschickt !';
}
?>
I think my Code works and there is nothing wrong...
Why is Joomla sending this mail 3 Times ?
www.picknstick.de <--- Online - Shop
How/Where can i search for this Problem ?
I've got an issue with PHPmailer getting stuck on my mail.php screen (usually it forwards the user to a success.html page). I've turned on error reporting, but still nothing shows up. I'm quite a noob at PHP, but it was working on my test URL before I moved it to the actual URL I wanted it to be on (just a few directories over on my server). Now I'm stuck on a white screen with no errors.
ALSO, I'm having an issue where on hotmail (and maybe some other providers--Gmail is working fine now) it's marking the emails as spam. I fixed a reverse DNS issue, but it's still marking the emails as spam. Any ideas on how to fix it? Please check my body and see if the content raises any red flags.
Here's the code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once('/var/www/includes/PHPMailer/PHPMailerAutoload.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
//gather variables from form//
$gmname = $_POST['gmname'];
$charname = $_POST['charname'];
$email = $_POST['email'];
$date = $_POST['date'];
$time = $_POST['time'];
$bantype = $_POST['radiogroup'];
$banreason = $_POST['banreason'];
//end gather//
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$body ="Attention account holder,<br \>This is a notice informing you that your Ashran account has been suspended. Please review the following information.<br \><br \>Account Name: $email<br \>Character Name: $charname<br \>Server: US - Grommash<br \>Ban Reason: $banreason<br \>Ban Type: $bantype<br \>Ban End Date: $date $time Server Time<br \>Banning staff member: $gmname<br \><br \>If you would like to appeal your ban because you feel that you were incorrectly punished, please follow the instructions in the following thread: Click Here<br \><br \>Do NOT reply to this email.";
//$body = eregi_replace("[\]",'',$body);//
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "----------#gmail.com"; // GMAIL username
$mail->Password = "----------"; // GMAIL password
$mail->SetFrom('----------#gmail.com', '------ -----');
$mail->AddReplyTo("---------#gmail.com","----- -----");
$mail->Subject = "Ashran - Account Suspension Notice";
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "$email";
$mail->AddAddress($address);
//Sets URL for forward after completion
$url = 'success.html';
//
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
header( "Location: $url" );
echo "Ban notice sent!!!";
}
?>
For the spam folder issue: If you find you're in a process where you're tweaking your content and then checking if it fixed your delivery problems, you can use inboxtrail.com's seed-based email deliverability test to see which email providers are dumping you to the spam folder after each content change. It's probably a good idea to re-test all the top providers, since for all you know a content change that solves the problem on hotmail could create new problems on gmail or yahoo or something. This should also tell you if the way your email server is configured is setting off any red flags.
I am trying to change the sender address of the mail. Firstly I tried by gmail, then I let to know that by gmail its not possible now I am trying using Yahoo, and I got following error:-
SMTP ERROR: MAIL FROM command failed: 553 From address not verified.
Getting blank here I dont understand what do I do? Any help will be appreciated. following is my code:-
<?php
//date_default_timezone_set('Etc/UTC');
require('PHPMailerAutoload.php');
$mail=new PHPMailer();
$mail->CharSet = 'UTF-8';
$body = 'This is the message';
$mail->IsSMTP();
$mail->Host = "plus.smtp.mail.yahoo.com";
//$mail->Host = 'smtp.gmail.com';
$mail->SMTPSecure = 'ssl';
$mail->Port = 465;
$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
$mail->Username = 'myyahooid#yahoo.com';
$mail->Password = 'xyz';
$name='Test Name';
$mail->Sender='thishavetoset#domain.com';
//$mail->From = 'sender#senderdomain.com';
//$mail->FromName = 'Sender Name';
$mail->SetFrom('thishavetoset#domain.com', $name, TRUE);
$mail->AddReplyTo('no-reply#mycomp.com','no-reply');
$mail->Subject = 'subject';
$mail->MsgHTML($body);
$mail->AddAddress('myyahooid#yahoo.com', 'title1');
//$mail->AddAddress('abc2#yahoo.com', 'title2'); /* ... */
$fileName='../rough/test.pdf';
$mail->AddAttachment($fileName);
//$mail->send();
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
?>
Let me know another solution to set the sender name also if you think, it can't be done this way. Thanks a ton in advance.
The sender email you using should be real email id and as your using Yahoo mail i think then it must registered in yahoo
There are two reasons smtp trows such error are.
first is You are attempting to send email to a domain that is not recognized by this server
second is You are attempting to relay email through this server and have not authenticated
Check if $mail->Sender='thishavetoset#domain.com'; email is set for your domain name your using.
So try to use email which user email password your using.
$mail->Username = 'myyahooid#yahoo.com';
In Gmail you can add that email id as external address from accounts and import tab >> add another email address, You will need details of smtp from the Admin of hosting/domain and add the email id.
once you add the external email address you can use that email id as sender from gmail smtp.
This question already has answers here:
PHP mail function doesn't complete sending of e-mail
(31 answers)
Closed 8 years ago.
I have a very simple contact form and a very simple php mail script. But when I tried to send it to the specified email address, I did not receive the test mail.
Below are my codes:
HTML Form
<div class="form" >
<form action="mail.php" method="post">
Email: <input type="text" name="email" size="38"><br>
詢問主旨:<input type="text" name="subject" size="36"><br>
<div class="queryTitle">
詢問內容
</div>
<br>
<textarea name = "message" rows="6" cols="37">
</textarea>
<br>
<input name = "submitted" type="submit" value="傳送">
</form>
</div>
Php script:
<?php
if (isset($_REQUEST['submitted'])) {
if (empty($errors)) {
$from = "From: ".$_REQUEST['email']."\r\n"; //Site name
// Change this to your email address you want to form sent to
$to = "verymeanguy2#gmail.com";
$subject = $_REQUEST['subject'];
$message = $from." ".$_REQUEST['message'];
mail($to,$subject,$message,$from);
}
}
?>
Could it be that Gmail blocked my mail? If so, how can I devise a script that can send mails to the popular mails?
Thanks in advance!
Jason
PS: I am hosting mine on heliohost's free Stevie server, if that accounts for something.
lolka_bolka: yes, mail() was called and adding an echo in front of mail function prints 1. And it's not in spam. Len_D: it did print anything, so I think mail was called and returned true. Anthony: how do I ensure that?
I just want to report back my testing. It seems that Gmail blocks Yahoo mail address sender for some reason. When the header is a Gmail address or even a bogus made-up address, Gmail can receive no problem. Yahoo mail on the other hand can receive mail with no problem at all. Anyone can shed a light on that?
When mail returns true (or 1), it means it did correctly what it tried to do. But doesn't always mean it sent mail at all.
the mail() funciton uses "sendmail" to actually send the email.
If sendmail is configured to send mail, then that's what will happen (it everything went ok).
However, by defult, sendmail stores mail in the server. It "simulates" a real sendmail.
From my personal experience, I recommend PHPMailer. It's easy to use, it's much easier to check for errors (check if the email was sent, and if not, get infomation about the problem).
Example:
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.server.com";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPSecure = "ssl";
$mail->Username = "email#domain.com";
$mail->Password = "password";
$mail->From = "email#domain.com";
$mail->FromName = "auto";
$mail->AddAddress("example#example.net", "Name of example user"); //send to....
$mail->IsHTML(true);
$mail->CharSet = "UTF-8";
$mail->Subject = "=?UTF-8?B?".base64_encode(stripslashes($asunto))."=?=";
$mail->Body = stripslashes($mensaje);
if(!$mail->Send()){
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
return true;
} else {
echo "Message has been sent";
return false;
}
Hope it helped :)
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);