我可以使用gmail作为我的网站的smtp服务器 [英] Can I use gmail as smtp server for my website

查看:211
本文介绍了我可以使用gmail作为我的网站的smtp服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想要一个网站开始运行。它目前在AWS上托管,所以我目前没有自己的smtp服务器运行。所以在阅读了几篇文章之后,我已经明白我们可以使用gmail作为smtp服务器。



我想加倍检查我读的是否正确,我要去要使用智能作业板软件,可以插入gmail提供的值并将其用作smtp服务器?

解决方案

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



有很多PHP邮件脚本可以使用。一些最受欢迎的SMTP发件人是: PHPMailer (有用的教程)和<一个href =http://swiftmailer.org/ =noreferrer> SWIFTMailer (和他们的教程)。



您需要从服务器连接和发送电子邮件的数据是您的 GMail 帐户,您的密码,他们的 SMTP服务器这种情况 smtp.gmail.com )和端口(在这种情况下 465 ),你也必须确保电子邮件正在通过SSL发送。



通过 PHPMailer

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

$ mail = new PHPMailer();

$ mail-> IsSMTP(); //告诉类使用SMTP
$ mail-> SMTPAuth = true; // SMTP认证
$ mail-> Host =smtp.gmail.com; // SMTP server
$ mail-> Port = 465; // SMTP Port
$ mail-> Username =john.doe@gmail.com; // SMTP帐户用户名
$ mail-> Password =your.password; // SMTP帐户密码

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

$ mail-> AddAddress('jane.doe@gmail.com','Jane Doe'); //收件人电子邮件

$ mail-> Subject =First SMTP Message; // email subject
$ mail-> Body =嗨!\\\
\\\
这是我通过使用PHPMailer的Google SMTP发送的第一封电子邮件。

if(!$ mail-> Send()){
echo'消息未发送。
echo'Mailer error:'。 $ MAIL-> ERRORINFO;
} else {
echo'已发送消息。
}
?>


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.

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??

解决方案

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

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).

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.

A quick example of sending an email like that with 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! \n\n 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服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆