我可以使用 gmail 作为我网站的 smtp 服务器吗

Can I use gmail as smtp server for my website(我可以使用 gmail 作为我网站的 smtp 服务器吗)
本文介绍了我可以使用 gmail 作为我网站的 smtp 服务器吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试建立一个网站并开始运行.它目前托管在 AWS 上,因此我目前没有运行自己的 smtp 服务器.所以看了几篇文章,我明白了我们可以用gmail作为smtp服务器.

Hello I am trying to get a website up and running. It is currently hosted on AWS, so I do not have my own smtp server running at this moment. So after reading a few articles, I have understood that we could used gmail as a smtp server.

我想仔细检查我读的是否正确,我将使用智能工作板软件,我可以插入 gmail 提供的值并将其用作 smtp 服务器吗??

I wanted to double check if what I read was right, I am going to use smart job board software, can I plug in the values provided by gmail and use that as an smtp server??

推荐答案

是的,Google 允许通过其 SMTP 进行连接,并允许您从您的 GMail 帐户发送电子邮件.

Yes, Google allows connections through their SMTP and allows you to send emails from your GMail account.

有很多 PHP 邮件脚本可供您使用.一些最受欢迎的 SMTP 发件人是:PHPMailer(带有有用的教程)和SWIFTMailer (以及他们的 教程).

There are a lot of PHP mail scripts that you can use. Some of the most popular SMTP senders are: PHPMailer (with an useful tutorial) and SWIFTMailer (and their tutorial).

从他们的服务器连接和发送电子邮件所需的数据是您的 GMail 帐户,您的 密码,他们的 SMTP 服务器(在本例中为 smtp.gmail.com)和端口(在本例中为 465)你也有确保通过 SSL 发送电子邮件.

The data you need to connect and send emails from their servers are your GMail account, your password, their SMTP server (in this case smtp.gmail.com) and port (in this case 465) also you have to make sure that emails are being sent over SSL.

使用 发送类似电子邮件的简单示例PHPMailer:

<?php
    require("class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->IsSMTP();  // telling the class to use SMTP
    $mail->SMTPAuth   = true; // SMTP authentication
    $mail->Host       = "smtp.gmail.com"; // SMTP server
    $mail->Port       = 465; // SMTP Port
    $mail->Username   = "john.doe@gmail.com"; // SMTP account username
    $mail->Password   = "your.password";        // SMTP account password

    $mail->SetFrom('john.doe@gmail.com', 'John Doe'); // FROM
    $mail->AddReplyTo('john.doe@gmail.com', 'John Doe'); // Reply TO

    $mail->AddAddress('jane.doe@gmail.com', 'Jane Doe'); // recipient email

    $mail->Subject    = "First SMTP Message"; // email subject
    $mail->Body       = "Hi! 

 This is my first e-mail sent through Google SMTP using PHPMailer.";

    if(!$mail->Send()) {
      echo 'Message was not sent.';
      echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
      echo 'Message has been sent.';
    }
?>

这篇关于我可以使用 gmail 作为我网站的 smtp 服务器吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)