Include ("class. phpmailer. php "); Include ("class. smtp. php "); // Obtain the content of an external file $ Mail = new PHPMailer (); $ Body = file_get_contents('contents.html '); $ Body = eregi_replace ("[\]", '', $ body ); // Set smtp Parameters $ Mail-> IsSMTP (); $ Mail-> SMTPAuth = true; $ Mail-> SMTPKeepAlive = true; $ Mail-> SMTPSecure = "ssl "; $ Mail-> Host = "smtp.gmail.com "; $ Mail-> Port = 465; // Enter your gmail account and password $ Mail-> Username = "yourname@gmail.com "; $ Mail-> Password = "password "; // Set the sender. It is best not to counterfeit the address. $ Mail-> From = "yourname@gmail.com "; $ Mail-> FromName = "Webmaster "; $ Mail-> Subject = "This is the subject "; $ Mail-> AltBody = $ body; $ Mail-> WordWrap = 50; // set word wrap $ Mail-> MsgHTML ($ body ); // Set the reply address $ Mail-> AddReplyTo ("yourname@gmail.com", "Webmaster "); // Add an attachment. The attachment and script are in the same directory. // Otherwise, enter the complete path $ Mail-> AddAttachment ("attachment.jpg "); $ Mail-> AddAttachment ("attachment.zip "); // Set the email address and name of the email recipient $ Mail-> AddAddress ("toname@gmail.com", "FirstName LastName "); // Send emails in HTML Format $ Mail-> IsHTML (true ); // Send an email using the Send Method // Process the data according to the sending result If (! $ Mail-> Send ()){ Echo "Mailer Error:". $ mail-> ErrorInfo; } Else { Echo "Message has been sent "; } |