I am working on sending some emails and PHPMailer have been working perfectly on my test server.
Now, after i moved it to the production server, none of my mails will fire and i am getting a
Mailer Error: Language string failed to load: instantiate.
I have been googling and toiling with phpmailer to see what seems to be the problem and from what i gathered, i was not able to make a regular php mail() request (this is the var that needs to return true for the error to stop
$rt = #mail($to, $this->EncodeHeader($this->Subject), $body,
$header, $params);
But even when setting subject and body to one word and the headers to the simplest kind
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
The mail function still returns false and i am really running out of ideas at this point
Anyone have anything to help me out with? It is getting extremly frustration at this point.
Thanks in advance
I think you are sending a subject header encoded as UTF-8, which the PHPMailer class would reject since it contained a perculiar swedish letter, namely “å”.
Something like that:
$subject = utf8_decode("Någon har svarat på din fråga på $site");
This converts the string to ISO-8859-1 encoding, which, of course, worked fine.
Related
i have a PHP variable that i construct like:
$msg_gifted='<body style="border:3px solid
black;padding:5rem;width:1000px;margin:auto;margin-top:30px;text-
align:center;">';
$msg_gifted.='<img src="/logo.png">';
$msg_gifted.='<h1>It is a mail </h1>';
$msg_gifted.='<p>From: ';
$msg_gifted.=$_POST["useremail"];
$msg_gifted.='</p>';
$msg_gifted.='<p>Amount: GBP';
$msg_gifted.=$_POST["amount"];
$msg_gifted.='<Some text </p>';
then i am sending this variable with mail
mail($recipient_gifted,$subject_gifted,$msg_gifted,$mailheaders_gifted);
everything works fine.
When i am adding some more staff to the variable then for some reason the mail never arrives
$msg_gifted='<body style="border:3px solid
black;padding:5rem;width:1000px;margin:auto;margin-top:30px;text-
align:center;">';
$msg_gifted.='<img src="/logo.png">';
$msg_gifted.='<h1>It is a mail </h1>';
$msg_gifted.='<p>From: ';
$msg_gifted.=$_POST["useremail"];
$msg_gifted.='</p>';
$msg_gifted.='<p>Amount: GBP';
$msg_gifted.=$_POST["amount"];
$msg_gifted.='<p>Some Text</p>';
$msg_gifted.='<p>';
$msg_gifted.='1000';
$msg_gifted.='</p>';
is there a limit for the variables?
You should consider using something like PHPMailer or SwiftMailer for sending E-Mails.
Most likely you got something wrong with the headers of the E-Mail. It's difficult to get them right, especially, when using mail for the first time.
Also, as far as I know, there's no such thing as a variable limit for mail(), have you already checked your server error logs?
Greetings
Edit:
As I thought it's a header based error.
i figured out it has to do with the headers.
the whole mail headers variable is:
$mailheaders_gifted = "From: " . $support_email . "\r\n";
$mailheaders_gifted .= "Reply-To: ". $support_email . "\r\n";
$mailheaders_gifted .= "MIME-Version: 1.0\r\n";
$mailheaders_gifted .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
I also tried :
"Content-type:text/html;charset=UTF-8" . "\r\n";
I still recommend to use one of the libraries I mentioned above.
Following from the PHP Docs for the mail function could solve the problem:
Note:
If messages are not received, try using a LF (\n) only. Some Unix mail
transfer agents (most notably » qmail) replace LF by CRLF
automatically (which leads to doubling CR if CRLF is used). This
should be a last resort, as it does not comply with » RFC 2822.
I finally managed to solve this. it was not a problem of how to setup the variable, but how to setup the headers.
i needed to edit my headers like:
$mailheaders_gifted[] = 'MIME-Version: 1.0';
$mailheaders_gifted[] = 'Content-type: text/html; charset=iso-8859-1';
$mailheaders_gifted[] = 'From: My Web Site <mymail#example.com>';
then the mail function should be:
mail($recipient_gifted,$subject_gifted,$msg_gifted,implode("\r\n",$mailheaders_gifted));
i am trying for send mail using php.My mail go to spam and some other errors are also in mail.
My header code is
$header_mail="select content from mail_header where id='1'";
$header_mail2=mysql_query($header_mail);
$fet=mysql_fetch_array($header_mail2);
$content= htmlentities($fet['content']);
$Headers = "From:$content\r\n" .
"Reply-To:$content\r\n" .
"Content-type: text/html; charset=UTF-8 \r\n";
$Headers.= "MIME-version: 1.0\n";
$Headers.= "Content-type: text/html; charset= iso-8859-1\n";
data in $content is zamisoft<zamisoft.com> but i got the mail as with
from: Zamisoft<
reply-to: Zamisoft<,
zamisoft#gmail.com>
I got the these message in mail
"Be careful with this message. Many people marked similar messages as phishing scams, so this might contain unsafe content. Learn more "
Mail is going to spam and errors are in header section part of mail.
Any body help me for solve these issue?
The problem is simple that the PHP mail() function is not using a well configured SMTP Server.
Nowadays Email-Clients and Servers perform massive checks on the emails sending server, like Reverse-DNS-Lookups, Graylisting and whatevs. All this tests will fail with the php mail() function. If you are using a dynamic ip, its even worse.
Use the PHPMailer-Class and configure it to use smtp-auth along with a well configured, dedicated SMTP Server (either a local one, or a remote one) and your problems are gone.
https://github.com/PHPMailer/PHPMailer
remove the htmlentities() from $content= htmlentities($fet['content']); and then try!
Since you are already setting the Content Type and Character Encoding, the contents of the array $fet['content'] will be read properly by the browsers!
htmlentities() converts the html tags to htmlentities (eg. < to <) which is what you are facing!!
Try it and let us know if the problem persists
Remove the line "Content-type: text/html; charset=UTF-8 \r\n"; as you have defined the header in the last line of header.
Add $Headers .= 'X-Mailer: PHP/' . phpversion()."\r\n"; at the last line of your code.
It tells which version of php is being used!
Also the email address should be a valid one as well!!
I am using php mail method to send HTML mails to people from my domain. I am using the following code to send mail
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type:text/html; charset=iso-8859-1' . "\r\n";
mail($id, $subject, $message,$headers);
However, the problem is that the code doesnt work when the size of message increases. It works fine for smaller messages.
Is there any way to overcome that ??
I resolved my issue. It was due to less number of breaking tags br in the html code. I introduced some br tags here and there and it flew :)
I have a php file that I am trying to send the output in a email using the php mail function (PHPMailer is not an option as the server I am working restricts their SMTP server). The code for the mail function is
$to = "xxx#example.com";
$subject = "Outdoor Grill Service Request";
ob_start();
require 'grill-form.php';
$body = ob_get_clean();
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers = "From: xxx#example.com\n";
mail($to,$subject,$body,$headers);
echo "Mail sent to $to";
grill-form.php is a php file that contains a html file that has tables that are populated with php variable from a form. This worked perfectly using PHPMailer but once I migrated over to standard php mail is got "screwy".
The issue I am running into is when the email sends I am getting raw HTML code and not the output of the grill-form.php (a styled table with values). I have little knowledge with the php mail function so I might be missing something stupid.
Was wondering what I am doing wrong. Thank you in advance for you help you people are the best.
Assuming that's your actual code, you're overwriting the $headers variable with the third declaration, not appending to what you have. The Content-type header is never making it in.
PHPMailer does support SMTP, by the way--what exactly do you mean by "restricts their SMTP server"? (Here's an example: http://phpmailer.worxware.com/index.php?pg=examplebsmtp)
I have a website in which I send a confirmation mail as part of the registration process.
Some time ago, I had some troubles with the mails I sent since I used no headers (PHP mail function).
Once I put some headers, I've gotten more responses from users, but I suspect that not every message reaches its destination.
How can I be sure that the messages reach their destination?
Which are the headers that can be considered a 'must'?
This is the code of my SendMail function
mail($to,
$subject,
$message,
"MIME-Version: 1.0\n".
"Content-type: text/plain; charset=ISO-8859-1; format=flowder\n".
"Content-Transfer-Encoding: 8bit\n".
"Message-Id: <" . md5(uniqid(microtime())) . "#mysite.com>\n".
"Return-Path: <admin#mysite.com>\n".
"X-Mailer: PHP v".phpversion()."\n".
"From: admin# mysite.com");
You should use external library for working with e-mails in php like PhpMailer , SwiftMailer or Zend_Mail. All your problems will go away.
The headers need a white space at the bottom to separate the header from main body.
Tools like Spam Assassin will give you a big mark down for that.
Also you should use \r\n as a line terminator instead of just \n
From PHP.net
Multiple extra headers should be separated with a CRLF (\r\n).
The headers seems quite good to me. The only glitch I see is an extra whitespace in the From header.
I'm sure you already checked it, but just in case ...
"From: admin# mysite.com");
should be (?)
"From: admin#mysite.com");
This is a working mail function I'm using for html mail and variable $return is defined to get error report from mail server in case of fail delivery.
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <'.$from.'>' . "\r\n";
$return = '-f'.$from;
#mail($to, $subject, $msg, $headers, $return);
you can see more detail at here sugunan.com
The headers look ok, except for the details pointed by #Eineki. Also if you are using Windows you need to send the $to param in the form "user#mail.com" and not "Username ", because it may cause trouble, due to the way the mail() function is implemented on windows platform, the "to" address may be parsed incorrectly.
You should add a Date: header (its mandatory by RFC5322) and some mail-clients may assume January 1 1970 as an e-mail date if none is given (and it gets lost between all the other old messages).