phpmailer / phpmailer Goto Github PK
View Code? Open in Web Editor NEWThe classic email sending library for PHP
License: GNU Lesser General Public License v2.1
The classic email sending library for PHP
License: GNU Lesser General Public License v2.1
Hi,
I have a problem with the "From" property in PHPMailer.
I'm using GMail (as SMTP and sender) and when I receive a mail sent by PHPMailer, it has the good "FromName" property but not the "From" one (it shows the SMTP address instead).
That's my code :
// SMTP Settings
$phpmailer->From = $settings['from_email'];
$phpmailer->FromName = $settings['from_name'];
Thanks !
The package on packagist.org uses Synchro's private clone URL, and as such composer fails with an SSH authentication error.
Please update the package to use the public clone URL.
this is a fork or a death project?
Firstly, thank you to all those who have contributed to PHPMailer and have made it the leading mail helper for PHP.
As per RFC 3676, could you please add 'format=flowed' mime type parameter to message bodies of content-type 'text/plain' and update the text accordingly or add a way of adding this parameter.
The main problem is that many mail systems "From-munge" in-transit messages by replacing all body text lines beginning with 'From ' with '>From '. Please see RFC 3676 section 4.4 for details. I believe this is to do with quoting of text when replying or forwarding messages. Because of this, if you write a plain text message that includes a line such as 'From mum with love', you'll find it has been prefixed with '>'.
Most modern mail clients including Thunderbird Mail, set the Content-Type of the plain text section to "text/plain; charset=ISO-8859-1; format=flowed" (or UTF-8 for charset) and use 'Space-Stuffing' on user inputted text to prevent lines from being munged (they prefix lines beginning with 'From ' or '>' or a space with ' '. There are also rules for how lines are soft wrapped that could be used in conjunction with the WordWrap option.
As a test, you can write an email in Thunderbird Mail to yourself that contains a line such as 'From blah' and view the message source on the sent or received message and you will see that the the 'From blah' line has been prefixed with a space and they always set the content type of plain text sections to include "format=flowed".
Here is RFC 3676 section 4.4 about Space-Stuffing:
4.4. Space-Stuffing
In order to allow for unquoted lines which start with ">", and to
protect against systems which "From-munge" in-transit messages
(modifying any line which starts with "From " to ">From "),
Format=Flowed provides for space-stuffing.Space-stuffing adds a single space to the start of any line which
needs protection when the message is generated. On reception, if the
first character of a line is a space, it is logically deleted. This
occurs after the test for a quoted line (which logically counts and
deletes any quote marks), and before the test for a flowed line.On generation, any unquoted lines which start with ">", and any lines
which start with a space or "From " MUST be space-stuffed. Other
lines MAY be space-stuffed as desired.(Note that space-stuffing is conceptually similar to dot-stuffing as
specified in [SMTP].)
To implement this, GetBoundary() would need to check for content type of 'plain/text' and append "format=flowed" to the "Content-Type: " string, and the plain body text would need to be updated using a simple regex to at least prefix 'From ' and lines beginning with a space. Lines beginning with '>' should indicate quoted reply/forwarded text but users can prefix these lines with a space themselves if need be if they do not want mail clients to automatically convert these to nicely formatted block quotes.
Currently we are telling our developers and design teams to ensure mail messages do not include lines starting with 'From ' such as 'From Account:' to avoid this minor but annoying mail artifact that mail clients hide from users for a reason.
I'm not sure if 'format=flowed' would be useful for other content-types like 'text/html' too, as lines starting with 'From ' are munged in HTML body content as well. Thunderbird Mail does NOT add "format=flowed" to HTML body text but that is because the HTML content is nicely indented.
Many thanks,
Brendan
Some parts of PHPMailer do not play nice with qmail, particularly its implementation of sendmail (in qmail-inject) as it's incompatible with some of the command line switches used by PHPMailer.
I've already implemented some of it in this branch, upgrading qmail to a whole new Mailer type rather than treating it as a flavour of sendmail. It should be working, but it needs testing in a qmail environment before merging into trunk.
when i turn on the debugging, i saw this lines of code... seems like something is changing my dfault PHPMailer setting to this domain server hence it will not work any more...my question is,,,where this code came from anyway? i did all my test in real time...is it possible that google or yahoo reported my ISP as a SPAMBOT? hence blocking my PHPMailer default and changing to this mail5002.site4now.net which i did not set? or my server is was hack? im using a microsoft hosting servers so can anyone hack microsoft server then?
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "220 mail5002.site4now.net "
SMTP -> get_lines(): $data is "220 mail5002.site4now.net "
SMTP -> FROM SERVER:220 mail5002.site4now.net
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250-mail5002.site4now.net Hello [10.10.28.130] "
SMTP -> get_lines(): $data is "250-mail5002.site4now.net Hello [10.10.28.130] "
SMTP -> get_lines(): $data was "250-mail5002.site4now.net Hello [10.10.28.130] "
SMTP -> get_lines(): $str is "250-SIZE 31457280 "
SMTP -> get_lines(): $data is "250-mail5002.site4now.net Hello [10.10.28.130] 250-SIZE 31457280 "
SMTP -> get_lines(): $data was "250-mail5002.site4now.net Hello [10.10.28.130] 250-SIZE 31457280 "
SMTP -> get_lines(): $str is "250-AUTH LOGIN CRAM-MD5 "
SMTP -> get_lines(): $data is "250-mail5002.site4now.net Hello [10.10.28.130] 250-SIZE 31457280 250-AUTH LOGIN CRAM-MD5 "
SMTP -> get_lines(): $data was "250-mail5002.site4now.net Hello [10.10.28.130] 250-SIZE 31457280 250-AUTH LOGIN CRAM-MD5 "
SMTP -> get_lines(): $str is "250 OK "
SMTP -> get_lines(): $data is "250-mail5002.site4now.net Hello [10.10.28.130] 250-SIZE 31457280 250-AUTH LOGIN CRAM-MD5 250 OK "
SMTP -> FROM SERVER: 250-mail5002.site4now.net Hello [10.10.28.130] 250-SIZE 31457280 250-AUTH LOGIN CRAM-MD5 250 OK
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 VXNlcm5hbWU6 "
SMTP -> get_lines(): $data is "334 VXNlcm5hbWU6 "
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "334 UGFzc3dvcmQ6 "
SMTP -> get_lines(): $data is "334 UGFzc3dvcmQ6 "
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "235 Authentication successful "
SMTP -> get_lines(): $data is "235 Authentication successful "
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "250 OK Sender ok "
SMTP -> get_lines(): $data is "250 OK Sender ok "
SMTP -> FROM SERVER:250 OK Sender ok
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is "550 No such user here "
SMTP -> get_lines(): $data is "550 No such user here "
SMTP -> FROM SERVER:550 No such user here
SMTP -> ERROR: RCPT not accepted from server: 550 No such user here
SMTP Error: The following recipients failed: [email protected]
The MsgHTML
function contains a 1-line html to text conversion that's over-simple and probably represents an XSS security hole. There are numerous options for better conversions such as html2text or by using an external converter (I like elinks as it can preserve table layouts in plain text). First step should be to break out a conversion function so that it's simple to add/override other converters later.
Hi
I've noticed on the last commit, that now inline images base64 encoded are wrongly attached to my mails, as before they were embedded.
Result before the change (open and close tags omitted for the cid lines):
--b2_66908324beade643ef61833062a95135
Content-Type: image/jpeg; name="E_maging_Compute_4e1573014c224.jpg"
Content-Transfer-Encoding: base64
Content-ID: vendor_image
Content-Disposition: inline; filename="E_maging_Compute_4e1573014c224.jpg"
Result with the new commits:
--b2_4c18b756c600578cfb921d1e3123e7c0
Content-Type: image/jpeg; name="E_maging_Compute_4e1573014c224.jpg"
Content-Transfer-Encoding: base64
Content-ID: [email protected]
Content-Disposition: inline; filename=E_maging_Compute_4e1573014c224.jpg
The "cid:" call of the image is the same for both source mail.
But in the second case, the image is broken and just attached to the mail (wrongly)
Line 2493 in class.phpmailer.php could be the one.
I don't know if the lacks of quotes could have an influence on that. Not yet test that point.
Anyway it's an RFC recomend so...
Thanks for the work ;)
Flagged by the IETF MsgLint application. The return path header is constructed by just appending the address to the header key, when it should be enclosed in <>.
Maybe slowpoke but happened to notice the boundaries are not enclose in quotes any more.
RFC 1521 - 7.2.1. : "This is not always necessary, but never hurts."
Content-Type: multipart/mixed;
boundary="gc0p4Jq0M:2Yt08jU534c0p"
When sending an email with valid email address I get warning:
PHP Warning: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: reference to non-existent subpattern at offset 10 in /var/www/acteo/guia/lib/class.phpmailer.php on line 738
And then error:
Mailer Error: You must provide at least one recipient email address.
Searching I've seen this is a known issue but I didn't find any solution, so I open an issue.
Thank you
I've tried to add A DKIM signature and it works if the body is just a few characters. If it's getting longer it fails.
I didn't found any solution yet
I've just written a program with some complex requirements for choosing recipients for emails. During development, I would have liked a way to output the headers and body of the email without actually sending it, in order to confirm that it is correctly configured.
They way I've done this so far is to first build up an array, which I can easily inspect, and then use that to configure the PHPMailer object.
Is there a way to do this with PHPMailer? If not, I think it would be a good feature.
Is there any plan to add CRAM-MD5 support?
There are quite a few missing translations. Can anyone help complete them?
To get a list of wha needs fixing, run test/phpmailerLangTest.php
with PHPUnit and it will give a list of all missing (and stray extra) translations.
Hello,
I install the bundle in laravel 3.2:
php artisan bundle:install phpmailer
Fetching [phpmailer]...done! Bundle installed.
But apears error mesagem:
Class phpmailer does not exist
Location:
/home/helder/php/zeladoria/laravel/ioc.php on line 155
Where am i mistaking ?
Helder
I believe there's a bug in PHPMailer for embedding images. The issue - as far as I can tell - is that that cid: use with AddEmbeddedImage is incorrect.
Around line 2491, this line exists:
$cid = 'cid:'. md5($url).'@phpmailer.0'; //RFC2392 S 2
This creates a string with the prefix of cid: at the front, which is later passed to AddEmbeddedImage and this appears to be the issue, as the cid: prefix should not be passed as part of the CID. Instead of embedding the image, it comes through as a standard attachment.
Here's how I fixed it. I removed the cid: prefix from here:
$cid = md5($url).'@phpmailer.0'; //RFC2392 S 2
And added it back in the preg_replace on line 2496 here:
$message = preg_replace("/".$images[1][$i]."=["']".preg_quote($url, '/')."["']/Ui", $images[1][$i]."="cid:".$cid.""", $message);
Test it out, make sure I'm making sense. Thanks!
So that we can run the test suite automatically without spamming anyone.
The EncodeHeader function has two problems:
This makes me think that the folding is applied at the wrong point. Header values should be encoded and returned, and folded later after combining with their keys. That said, I don't know if Q and B encoded headers really need their prefixes applied on every line, which is what they are doing at present.
Update: Q and B encodings do need their prefixes repeating on each line because an RFC 2047 'encoded-word' may not contain white space, and thus cannot be folded.
When instantiating SMTP object, the latest doesn't receive the value of the do_verp variable, and it is not possible to use XVERP extension on the corresponding SMTP server.
It can be fixed by inserting on line 1062 in class.phpmailer.php the following line:
$this->smtp->do_verp = $this->do_verp;
On google code, this was reported as added to the 5.2.2 code, but I just tried, and it's not there on 5.2.5
probably due to the move from google to github.
If i leave te default date format, i get twice +100
This : $result = sprintf("%s %s%04d", date('D, j M Y H:i:s O'), $tzs, $tz);
Gives in logs : CLIENT -> SMTP: Date: Thu, 28 Mar 2013 11:18:13 +0100 +0100
So i changed it to : $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz);
(deleted the O option in date function)
I've tried a basic email like [email protected] and the function returns false. Here is a better one:
function ValidateAddress($email){
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quoted_pair = '\\x5c[\\x00-\\x7f]';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
}
1.wrong message by throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL);
2.At function SmtpSend($header, $body)
3.Method "$this->smtp->Mail($smtp_from)"
This function will check the connection and some error reporting.
But $this->Lang('from_failed') is just say "wrong from address".
We can be output more helpful messages.
Regards,
Yoshi Sakai
Migrate/fix/close issues from the Google Code repo.
Three minor code errors in /test_script/index.php:
Line 190 ... "Assigning the return value of new by reference is deprecated"
Fix by changing $h2t =& new html2text($body);
to $h2t = new html2text($body);
Line 213 ... "Undefined variable: errorMsg"
Fix by changing if ( count($errorMsg) > 0 ) {
to if ( isset($errorMsg) && count($errorMsg) > 0 ) {
Not sure how/where to fix, but the inline image is received as a broken image in gmail (after clicking "Display images below").
Jim,
The Google code project is still pointing at my personal fork. Could you please update it to point at https://github.com/PHPMailer/PHPMailer
.
Thanks
Please make stable release available via Packagist - currently there is only dev-master.
Hi,
I suggest changing the default value of the $auto
argument in PHPMailer::setFrom
to 0
. Currently every call to ::setFrom
also sets the Reply-To
header, which is not expected. Especially for old code ported to the new PHPMailer source.
Adding From as Reply-To also serves no purpose, if no other Reply-To is set. Currently the actions of ::setFrom depends on the invocation order in PHPMailer (other behaviour, if Reply-To is already set), which is a violation of the orthogonality criteria for API developers.
If you embed images and use two files with the same name (but different path) phpMailer always strips out one of them
The fix is simple:
on line 2422 change
$cid = 'cid:' . md5($filename);
to
$cid = 'cid:' . md5($url);
this will generate a md5 from the whole file path instead just the filename
An umbrella ticket to remind us to fix the remaining bugs logged on SourceForge. Tickets marked as 'accepted' have been confirmed to still exist in the current version. Those marked 'open' have not been confirmed.
Ok, this is the first bug that I ever report on github, so if don´t follow the proper formatting please tell me. By implementing the SMTP example I got the error "could not connect to SMTP host", The fix was to comment out $mail->IsSMTP();
. Is this a bug or is it just bad implementation on my part?
It seems like more people have had similar issues since I found the quick fix on http://stackoverflow.com/questions/1233291/problem-with-smtp-authentication-in-php-using-phpmailer-with-pear-mail-works.
Hi people, anybody knows why i get this error, "Mailer Error: Could not execute: /var/qmail/bin/sendmail" or "Could not instantiate mail function." in every example i try to test.
I'm using WAMP for this.
Hi,
while the tag clearly states the 5.2.6 release, the sourcecode of class.phpmailer.php still refers to itself as 5.2.5 while class.smtp.php remained at 5.2.4
Hello,
I just saw the "IsSmtp" was obsolete.
By What should replace it ?
The examples you provide always use.
thank you
Calendar events are typically sent by email in a three-part multipart/alternative MIME structure where the parts are text/html, text/plain and text/calendar. Because PHPMailer doesn't support arbitrary MIME structures, only a selection of presets, it's not possible to use it to construct a message like this, and some recent changes make it difficult to manipulate the MIME structure to accommodate it.
There is some example code for sending such messages here, but it would be nice to roll this into PHPMailer.
This isnt a real issue rather a question.
I'm using phpMailer in a WordPress plugin and send HTML mails. This works very well. But unfortunataly some users have these strange characters on german Umlauts and the for instance.
This normally happens when using a different charset rather than UTF-8 but this is not the case. I don't allow users to change that and as long they don't change the code (what they don't do) there are no hooks or filters to change it too.
The strangest thing is when they send me the exact same message to me and I have no problems on my iPhone
Has anyone experienced similar? I hardly get this support request but every time I have to say that I don't know an answer.
Hi guys,
I noticed that a number of tags from Google Code repository are missing here (from 5.2.0 to 5.2.4), It would be nice if you could add them.
Cheers
MsgHTML()
always overwrites the value of Body
, but if AltBody
has already been set to a non-empty value, it's left untouched. This doesn't make sense when AltBody
is populated by MsgHTML
if it is initially empty, meaning that subsequent calls to MsgHTML
will change Body
but not AltBody
. This is probably unexpected if you're creating and sending messages in a loop. If you want AltBody
to be kept, it's simple to set it after calling MsgHTML
, or simply don't use MsgHTML
in the first place. The whole point of MsgHTML
is to make message setup simpler, so it should overwrite AltBody
every time.
This issue was originally reported on sourceforge by Thilo Muller.
Hi,
I've been using phpMailer for sometime and its been great.
I have just moved over to a new web hosting company and now it will not work. Even the most basic example.
I have PHP 5.3.3 running on the server
its a Linux server
the error back from php mailer is,
Message was not sent.Mailer error: You must provide at least one recipient email address.
I know its a valid email address.
The error message in the web hosting log is this,
[Wed Jan 23 18:47:49 2013] [warn] [client 82.68.41.46] mod_fcgid: stderr: PHP Warning: preg_match() [function.preg-match]: Compilation failed: reference to non-existent subpattern at offset 10 in /var/www/vhosts/vision-link.co.uk/site1/VL_Mail/class.phpmailer.php on line 667
any ideas? I'm a bit stuck really..
many thanks,
Patrick
I see a lot of messages sent by PHPMailer that clearly have had their bodies supplied with UNIX LF line breaks, and when they get q-p encoded, look very ugly and almost unreadable as all the line breaks turn into =0A
and the text ends up as a solid block, thus defeating much of the point of q-p encoding. Worse than that, I also see quite a lot of bodies supplied with mixed line break formats (e.g. where a CRLF template has LF content injected into it) that make even more of a mess.
Normalizing line breaks to CRLF in HTML and plain-text bodies would result in much better looking and more readable emails, as well as saving 1 char for every line break.
If this is done in MsgHTML, which is very much a convenience function that does lots of things for you already, it would still allow setting of non-normalized message bodies by setting Body and AltBody directly.
Just wondering if anyone had any comment on this before I implement it.
Hi,
Im using the Sign() method to sign my emails with a certificte. Unfortunatly the headers generated by this method are not places under the existing headers, resulting in an email containing these headers in Outlook.
The message is readable in GMail, but if you click 'view original' you can see the headers being wrongly places.
Example:
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha1"; boundary="----A15A468A5619A1EEEBA97BAD3B034332"
This is an S/MIME signed message
------A15A468A5619A1EEEBA97BAD3B034332
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="iso-8859-1"
This shows up in the Outlook email
I would like to see a helper function that validates a email address before attempting to send a message.
PHPMailer currently fails to send to addresses that contain "(" '"' and " ", as claimed to be valid on Wikipedia http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses
So The following 'vaild' examples don't work
(Comment)[email protected]
My."FunkyText"[email protected]
Ihavea"[email protected]
My SPACY [email protected]
Yes Wikipedia can be wrong, but in any-case I would like to pre-validate that an address is syntactically correct before making a class instance.
Posted here some time ago: https://code.google.com/a/apache-extras.org/p/phpmailer/issues/detail?id=149 , didn't know you switched to GitHub.
Reported by [email protected], May 26, 2013
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Expected: DKIM pass even if you're using a certificate to sign an e-mail or not.
Instead: "Result: fail (wrong body hash: expected C49jdpzgT23JFade5ud2KbKBHdQ=)" from [[email protected]] if you Sign() the mail with the certificate.
What version of the product are you using? On what operating system?
PHPMailer 5.2.6, PHP 5.3, CentOS
Please provide any additional information below.
Some code:
//DKIM STUFF
$m -> DKIM_domain = 'domain.com';
$m -> DKIM_private = './.dkim.txt';
$m -> DKIM_selector = 'domain.com';
//DIGITALY SIGN E-MAIL WITH A CERTIFICATE
$m -> Sign('./.cert.pem', './.cert.pem', "certPassword");
This is part of the code.
If I comment out the line with the Sign() method, the DKIM check passes. If I let it there, I get my e-mail digitally signed with the certificate, but DKIM fails.
#1 [email protected]
Forgot to mention that it doesn't work as it should ( = DKIM doesn't pass), even if you call the Sign() method before or after setting the DKIM variables.
I would like to be able to set a content-id on attachement, in order to include it in an image in my e-mail (src="cid:012345")
Hi folks,
I've noticed that both
$mail->MsgHTML($body);
and
$mail->IsHTML(true);
$mail->Body = $body;
will fail to send an email without throwing an error if $body does not begin and end with the appropriate HTML and BODY tags. I'm not sure if this is a bug or if it should be a requested feature (or if I should just format my HTML emails appropriately), but I've seen a few people trying to figure out what's going on, so I thought I'd throw it out there.
Thanks!
When I'm using phpmailer on a Server CentOS 6.4, php 5.4.4( XAMPP ), and PCRE_VERSION 8.12 2011-01-15, I always got Fatal error: Maximum execution time of 30 seconds exceeded in /class.phpmailer.php on line 754. I find that is a method ValidateAddress(), which uses regular expression. After I commented regular expressions , the script can complete.
Besides the same script regular expression version run normally on my windows pc.
Hi,
Is it possible at all to retrieve the message ID after sending by sendmail (not SMTP) ?
In line 271 in phpmailer.inc.php file there is line:
$header[] = sprintf("Content-Transfer-Encoding: %s\n", $this->$Encoding);
$ sine before Encoding ($Encoding) causes error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.