as follows:
Memory_limit = 128 M; // change 256 M to M
However, when a php script requests more than 128 MB of memory at a time, no matter how large the memory_limit will be, there will certainly be problems in the future.
The reason is that when coding, I only assign values to variables, but never unset ($ var. As a result, the memory usage is increasing, so after a variable is no longer used, remember to unset it.
The following is the code used to process the log file today:
The code is as
Jmail is a third-party mail operation component, usually located on the web server, to achieve mail receiving and sending functions (the client can use Foxmail ). It can be used to easily implement the functions of sending, CC, BCC, sending, logging, and email receiving. This chapter focuses on mail, CC, BCC, multiple sending, and log records.
I. Component preparationDownload and install JMail44_pro (write down the installation path)
Find the installation path,Copy jmail. dll to the project.
Ii.
1. Set the sender name and sender email of general contact in system-> Configuration-> store email addresses.
Sender name is the sender of the email, and sender email is the sender's email address.
2. Configure mail sending settings in system> Configuration> system. The configuration is as follows:
At present, I do not understand the role of set return-path. I will add instructions later.
3. Override the getmail () method in mage_core_model_email_tem
Bromon originality, please respect copyright
Ii. receiving emails
Generally, we use the POP3 protocol to receive emails. imap does not involve emails now. Although it takes me a lot of time to figure out the mail receiving function, it is so easy. A program can basically include it.
There are roughly three types of Emails: plain text emails, text emails containing other data, and emails containing attachments.
Code/** Created on 2004-4-26*/Package org. bromon. mail;Import javax. Mail .*;Import
!= "")
???? {
????? Mymail.addattachment (model. Filename,false,model. FileType);//Add message Attachments
????}
???? Mymail.priority =model. Priority; How urgent the message is
???? Mymail.mailserverusername = model. Mailserverusername; User name for landing mail server
???? Mymail.mailserverpassword = model. Mailserverpassword; Login password for mail server
???? return Mymail.send (model. Maildomain,false); Mail server address (example: smtp.163.com)
???}
??? catch (Exception ex)
??? {
??
POP3 to receive the mail class in the previous article has given you a detailed introduction, below we look at how to apply this class:
Include ("pop3.inc.php (as current mainstream development language)");
$host = "pop.china.com";
$user = "Boss_ch";
$pass = "026007";
$rec =new POP3 ($host, 110,2);
if (! $rec->open ()) Die ($rec->err_str);
echo "OPEN";
if (! $rec->login ($user, $pass)) die ($rec->err_str);
echo "Login";
if (! $rec->stat
The template variable replacement technique is often used when sending mail in batches, that is, a mail template with built-in variable identifier, and then a series of replicas Based on the recipient to generate the corresponding new mail. When the mail template format is fixed (mainly encoding, mail body format), it is easy to implement. Then, it is complicated to allow users to upload mail templates. The Code is as follows:
Import sys, OS, email, base64, email. header, quopri, reclass MailTpl
{
Echo "letter". $ rec-> mail_list [$ I] [num]. "Size:". $ rec-> mail_list [$ I] [size]."";
}
$ Rec-> getmail (1 );
Echo "mail header content:";
For ($ I = 0; $ ihead); $ I ++)
Echo htmlspecialchars ($ rec-> head [$ I])."N ";
Echo "email body:";
For ($ I = 0; $ ibody); $ I ++)
Echo htmlspecialchars ($ rec-> body [$ I])."N ";
}
$ Rec-> close ();
?>
If you set debug in POP3 to true, you can also seeProgramThe dialog with POP
, $ pass) die ($ rec-> err_str );
If (! $ Rec-> stat () die ($ rec-> err_str );
Echo "a total of". $ rec-> messages. "mails, a total of". $ rec-> size. "bytes
";
If ($ rec-> messages> 0)
{
If (! $ Rec-> listmail () die ($ rec-> err_str );
Echo "the following is the Mail content:
";
For ($ I = 1; $ I
{
Echo "letter". $ rec-> mail_list [$ I] [num]. ", size:". $ rec-> mail_list [$ I] [size]."
";
$ Rec-> getmail ($ rec-> mail_list [$ I] [num]);
($ I = 1; $ I {
Echo "letter". $ rec-> mail_list [$ I] [num]. "size:". $ rec-> mail_list [$ I] [size]."";
}
$ Rec-> getmail (1 );
Echo "mail header content:";
For ($ I = 0; $ I
Head); $ I ++)
Echo htmlspecialchars ($ rec-> head [$ I])."\ N ";
Echo "email body:";
For ($ I = 0; $ I
Body); $ I ++)
Echo htmlspecialchars ($ rec-> body [$ I])."\ N ";}
$ Rec-> close ();?>
If you set debug to true in the pop3 class, you can also see how the pro
How can I filter mails obtained by IMap ?? Who did it? Consulted lt ;? Phprequire_once (.. imapMailbox. php); nbsp; IMAP nbsp; must nbsp; be nbsp; enabled nbsp; in nbsp; Google nbsp; Mail nbsp; settingsdefine (GMAIL_EMAI IMap) how can I filter emails by getting the mail content ?? Who did it? Consulted
Require_once ('../ImapMailbox. php ');// IMAP must be enabled in Google Mail SettingsDefine ('Gmail _ e-mail ','');Define ('Gmail _ password ','');Define ('attachments _ dir', dirname
(! $rec->login ($user, $pass)) die ($rec->err_str);
if (! $rec->stat ()) Die ($rec->err_str);
echo "Shared". $rec->messages. " Letter, Total ". $rec->size." BYTE size
";
if ($rec->messages>0)
{
if (! $rec->listmail ()) Die ($rec->err_str);
echo "The following are the contents of the letter:
";
for ($i =1; $i
{
echo "letter". $rec->mail_list[$i][num]. ", Size:". $rec->mail_list[$i][size]. "
";
$rec->getmail ($rec->mail_list[$i][num]);
$deco
Application examples
POP3 to receive the mail class in the previous article has given you a detailed introduction, below we look at how to apply this class:
Include ("pop3.inc.php");
$host = "pop.china.com";
$user = "Boss_ch";
$pass = "026007";
$rec =new POP3 ($host, 110,2);
if (! $rec->open ()) Die ($rec->err_str);
echo "OPEN";
if (! $rec->login ($user, $pass)) die ($rec->err_str);
echo "Login";
if (! $rec->stat ()) Die ($rec->err_str);
echo "Shared". $rec->messages. " Letter, Total ". $re
; } public String getMail() { return this.mail; } public void setMail(String value) { this.mail = value; }}
3. Calling through Business Objects
Create the class "ContactsService" under the package "com. kxh. example. demo. service ".
In the class, "EntityManager" is introduced, and the @ Autowired annotation is instantiated by the framework.
Use "EntityManager" to create a named stored procedure function, and pass
The POP3 mail receiving class has already been described in detail in the previous article. Let's take a look at how to apply this class:
Include ("pop3.inc. php (as the mainstream development language )"); $ Host = "pop.china.com "; $ User = "boss_ch "; $ Pass = "026007 "; $ Rec = new pop3 ($ host, 110,2 ); If (! $ Rec-> open () die ($ rec-> err_str ); Echo "open "; If (! $ Rec-> login ($ user, $ pass) die ($ rec-> err_str ); Echo "login "; If (! $ Rec-> stat () die ($ rec-> err
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.