[Emergency] use Zend_Mail to construct the mail delivery form. smtp has problems.

Source: Internet
Author: User
Tags gmail password
[Emergency] use Zend_Mail to build the Mail Form. if smtp has a problem, I wrote a piece of code today and used Zend_Mail to build the Mail form. The program has never been running successfully, I suspect that there is a problem with my smtp configuration. in actual operation, $ smtp = newZend_Mail_Transport_Smtp (& qu [emergency] uses Zend_Mail to construct the mail delivery form. smtp has a problem.
Today, I wrote a piece of code and used Zend_Mail to construct the mail delivery form. The program is always unsuccessful. I suspect there is a problem with my smtp configuration.
$ Smtp = new Zend_Mail_Transport_Smtp ("smtp.gmail.com ",
Array (
'Port' => '25 ',
'Auth' => 'login ',
'Username' => 'xxxx @ gmail.com ',
'Password' => 'xxxxx'
));
Username and password all use real available mailboxes, and their brothers help to see where the problem is, 3Q
The overall code is as follows:



Email Delivery


Send email to Zend_Mail

Function encode ($ str ){
Return mb_convert_encoding ($ str, "gb2312", "auto ");
}
If ($ _ POST ['submit ']! = Null ){
Require_once 'zend/Mail. php ';
Require_once 'zend/Mail/Transport/Smtp. php ';
$ Smtp = new Zend_Mail_Transport_Smtp ("smtp.gmail.com ",
Array (
'Port' => '25 ',
'Auth' => 'login ',
'Username' => 'xxxx @ gmail.com ',
'Password' => 'xxxxx'
));
Zend_Mail: setDefaultTransport ($ smtp );

$ Mail = new Zend_Mail ();
$ Mail-> addTo ($ _ POST ['to']);
$ Mail-> setForm ("Circleinthehouse@gmail.com", encode ("Tian Jia "));
$ Mail-> setSubject (encode ($ _ POST ['subobject']);
$ Mail-> setBodyHtml (encode ($ _ POST ['body']);
$ Attach = $ mail-> createAttachment (file_get_contents ($ _ FILES ['fl '] ['tmp _ name']);
$ Attach-> type = $ _ FILES ['fl '] ['type'];
$ Attach-> filename = $ _ FILES ['fl '] ['name'];
$ Mail-> send ();
Print ("email sent successfully! ");
}
?>




------ Solution --------------------
SMTP Port error. The GMAIL port is not 25. refer to the official GMAIL instructions:

Other email client configurations

Standard description:

Enable POP in Gmail. Do not forget to click save changes after the operation is complete.
Configure your client to match the following settings:
Receiving mail (POP3) server-requires SSL: pop.gmail.com
Use SSL: Yes
Port 995
Send mail (SMTP) server-TLS or SSL: smtp.gmail.com (use authentication)
Use authentication: Yes
TLS/STARTTLS Port: 587
SSL port 465
Account name: your complete email address (including @ gmail.com or @ your_domain.com)
Email address: Your email address (username@gmail.com or username@your_domain.com)
Password: your Gmail password
------ Solution --------------------
Array (
'Port' => '25 ',
'Auth' => 'login ',
'Username' => 'xxxx @ gmail.com ',
'Password' => 'xxxxx'
));


To:

PHP code
array('port' => '587','auth' => 'login','username' => 'XXXX@gmail.com','password' => 'XXXXX'));

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.