Why does phpmailer send emails through gmail?

Source: Internet
Author: User
Tags gmail mail
How can I send emails through gmail? I use a laptop host and apply for the email server created in it. then, I can send a message with phpmailer. I just want to change it to "stackoverflow" because I lost my mail via gmail. comques... {code ...... how can I send emails through gmail?
I use a laptop host and apply for the email server created in it. then, I can send a message with phpmailer.
I just want to change it to mail via gmail.
So I lost my account.
Here I am: http://stackoverflow.com/ques...

$mail = new PHPMailer();$mail->IsSMTP(); // enable SMTP$mail->SMTPDebug = 1; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Host = "smtp.gmail.com";$mail->Port = 465; $mail->IsHTML(true);$mail->Username = "***@gmail.com";$mail->Password = "***";$mail->SetFrom("***@gmail.com");$mail->Subject = "Test";$mail->Body = "hello";$mail->AddAddress("xxxxxxxx@gmail.com"); if(!$mail->Send()) {    echo "Mailer Error: " . $mail->ErrorInfo; } else {    echo "Message has been sent"; }

SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: ***@gmail.com : Called Mail() without being connected Mailer Error: The following From address failed: ***@gmail.com : Called Mail() without being connected

Are you sure you want to disable gmail authentication?

It turns out that bluehost cannot use gmail.

Reply content:

How can I send emails through gmail?
I use a laptop host and apply for the email server created in it. then, I can send a message with phpmailer.
I just want to change it to mail via gmail.
So I lost my account.
Here I am: http://stackoverflow.com/ques...

$mail = new PHPMailer();$mail->IsSMTP(); // enable SMTP$mail->SMTPDebug = 1; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Host = "smtp.gmail.com";$mail->Port = 465; $mail->IsHTML(true);$mail->Username = "***@gmail.com";$mail->Password = "***";$mail->SetFrom("***@gmail.com");$mail->Subject = "Test";$mail->Body = "hello";$mail->AddAddress("xxxxxxxx@gmail.com"); if(!$mail->Send()) {    echo "Mailer Error: " . $mail->ErrorInfo; } else {    echo "Message has been sent"; }

SMTP -> ERROR: Failed to connect to server: Connection timed out (110) The following From address failed: ***@gmail.com : Called Mail() without being connected Mailer Error: The following From address failed: ***@gmail.com : Called Mail() without being connected

Are you sure you want to disable gmail authentication?

It turns out that bluehost cannot use gmail.

The connection times out. what about the host? can I access the google service?

First test your code locally to see if there is any problem. if there is no problem, consult the VM supplier.

The error message indicates that the network of the code server cannot access the gmail mail server.

Not connected to '$ mail-> Host = "smtp.gmail.com ";'

Smtp POP3 or IMAP protocol

Related Article

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.