163 Mailbox |
POP3 Server: pop.163.com SMTP Server: smtp.163.com |
|
Yahoo Mail |
Note: Yahoo in foxmail more than 4.1 of the version set as follows: (Outlook not yo ~) |
POP3 Server: pop.mail.yahoo.com.cn SMTP server: smtp.mail.yahoo.com.cn |
|
Sohu Mailbox |
POP3 Server: pop3.sohu.com SMTP server: smtp.sohu.com |
|
Gmail Mail |
The first step: To manually configure: POP3 server is pop.gmail.com SMTP Server is ssl://smtp.gmail.com Step Two: Use automatic configuration file Http://toolbar.google.com/gmail-helper/GmailConfig.exe This is OK ~ can send and receive Gmail mail. |
QQ Mail |
POP3 Server: pop.qq.com SMTP server: smtp.qq.com The SMTP server requires authentication. |
http://www.fwolf.com/blog/post/155--phpmailer email with Gmail account
Phpmailer (now the version is 1.73) is a very useful tool, you can easily use the PHP language to send mail, support SMTP and authentication, we always use it.
However, because Gmail has an SSL connection to SMTP: Outgoing Mail (SMTP) server-requires TLS:smtp.gmail.com (use authentication)
Use Authentication:yes
Use Starttls:yes (some clients call this SSL)
port:465 or 587
Use of Phpmailer can not normally connect Gmail's sending server, and this problem has not been Phpmailer official solution, but in the sf.net above the discussion is found a bit of information, using the following method can connect Gmail.
Modify class.smtp.php, line 101th, $this->smtp_conn = Fsockopen ($host, # The host of the server
Change to $this->smtp_conn = Fsockopen (' ssl://'. $host, # The host of the server
This is OK, is to specify the use of SSL protocol to connect the host, of course, PHP OpenSSL module must be open: Extension=php_openssl.dll
Instead of using a non-SSL host, I don't like to put two Phpmailer under the Include directory, so I figured out a better way:
Open class.phpmailer.php, near 543 lines, function Smtpconnect (), find: $this->smtp->do_debug = $this->smtpdebug;
$hosts = Explode (";", $this->host);
$index = 0;
$connection = ($this->smtp->connected ());
Retry while there is no connection
while ($index < count ($hosts) && $connection = = False)
{
if (Strstr ($hosts [$index], ":"))
List ($host, $port) = Explode (":", $hosts [$index]);
Else
{
$host = $hosts [$index];
$port = $this->port;
}
Part of the function of this section is that if you enter the host name with the port number, automatically identified, although the idea is good, but this is the part of the call we can not directly use the SSL format of the host name, because the "ssl://xxx" form will be mistaken for the host: the form of the port number, The other port number is generally more fixed, we manually set up, also do not have to have to assign values with the host, so add after the code above://modify by Fwolf @ 2006-4-14, to enable SSL mail connection
$host = $this->host;
$port = $this->port;
On it, use the normal SMTP host, the usage is unchanged, use Gmail, use ssl://smtp.gmail.com as host name, the only slightly trouble is that the port needs to manually specify-in fact, not trouble.
Following the configuration changes above, there will also be a warning message when you use the Gmail account to send a message: Warning:fgets (): Ssl:fatal protocol error in H:\PHP_INCLUDES\PHPMAILER_SSL\CLA
ss.smtp.php on line 1024
This warning message in the help of PHP, as if the use of SSL connection, read the file read the file at the end of the problem, the need for manual shielding, or artificial control of the length of reading, we use the simplest way to prohibit the warning message display on it, Find the 1024 lines of class.smtp.php and add a @ to the fgets ($this->smtp_conn,515) function.
Here is a complete function to send mail using Phpmailer: function Send_mail ($to _address, $to _name, $subject, $body, $attach = ")
{
Send mail using Phpmailer
Require_once ("phpmailer/class.phpmailer.php");
$mail = new Phpmailer ();
$mail->issmtp (); Set Mailer to use SMTP
$mail->charset = ' utf-8′;
$mail->encoding = ' base64′;
$mail->from = ' fwolf.mailagent@gmail.com ';
$mail->fromname = ' Fwolf ';
$mail->sender = ' fwolf.mailagent@gmail.com ';
$mail->confirmreadingto = ' fwolf.mailagent@gmail.com '; Receipt.
$mail->host = ' ssl://smtp.gmail.com ';
$mail->port = 465; Default is, Gmail is 465 or 587
$mail->smtpauth = true;
$mail->username = "fwolf.mailagent@gmail.com";
$mail->password = "xxx";
$mail->>ddaddress ($to _address, $to _name);
$mail->addreplyto (' fwolf.mailagent@gmail.com ', "Fwolf"); For Gmail is useless, Gmail is in-reply-to:,phpmailer default generated is reply-to:
$mail->wordwrap = 50;
if (!empty ($attach))
$mail->addattachment ($attach);
$mail->ishtml (FALSE);
$mail->subject = $subject;
$mail->body = $body;
$mail->altbody = "This are the body in plain text for non-html mail clients";
if (! $mail->send ())
{
echo "Mail send failed.\r\n";
echo "Error message:". $mail->errorinfo. "\ r \ n";
return false;
}
Else
{
Echo ("Send $attach to $to _name < $to _address> successed.\r\n");
return true;
}
echo "Message has been sent";
//
} update @ 2006-11-3
Thank Rainchen for a better solution to the fgets error hint (the location is approximately 1024 lines in class.smtp.php):
Will: Fgets ($this->smtp_conn,515)
Instead:!feof ($this->smtp_conn) && $str = fgets ($this->smtp_conn,515)
Such code is much more standardized and strongly discouraged from using @ to block error messages.
http://www.fwolf.com/blog/post/176----Phpmailer supporting the Chinese name of the attachment
Http://hi.baidu.com/keepsky/blog/item/3ff9eb13144c470f5baf5318.html
http://www.jiucool.com/phpmailer-php-email/