Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use gmail as smtp server for my website

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

like image 580
macha Avatar asked Aug 30 '12 04:08

macha


People also ask

Can I use Gmail as an SMTP server?

Use the Gmail SMTP serverIf you connect using SSL or TLS, you can send mail to anyone inside or outside of your organization using smtp.gmail.com as your server. This option requires you to authenticate with your Gmail or Google Workspace account and passwords.

Is Gmail SMTP server free?

The SMTP server for Gmail is a free SMTP server that anyone across the globe can use. It allows you to manage email transactions from your Gmail account via email clients or web applications.

Can I use Gmail for SMTP relay?

If your organization uses Microsoft Exchange or another SMTP service or server, you can set up the SMTP relay service to route outgoing mail through Google. You can use it to: Filter messages for spam and viruses before they reach external recipients. Apply email security and advanced Gmail settings to outgoing ...

How do I create a Gmail SMTP server?

Configuring Custom SMTP Settings for Gmail In the left-hand sidebar menu, click on 'SMTP Overrides. ' Ensure that the email address and authentication username match your Google App's email address. The password will be your Google/Gmail password if you do not have multi-factor authentication turned on.


3 Answers

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   = "[email protected]"; // SMTP account username
    $mail->Password   = "your.password";        // SMTP account password

    $mail->SetFrom('[email protected]', 'John Doe'); // FROM
    $mail->AddReplyTo('[email protected]', 'John Doe'); // Reply TO

    $mail->AddAddress('[email protected]', '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.';
    }
?>
like image 181
Mihai Iorga Avatar answered Oct 22 '22 21:10

Mihai Iorga


I successfully use the GMail SMTP server.

We do have a corporate GMail account, though I don't think that matters. A personal GMail account should suffice.

I do not have a PHP sample however the following configuration for ASP.Net should provide adequate guidance:

<mailSettings>
  <smtp from="[email protected]">
    <network enableSsl="true" host="smtp.gmail.com" port="587" userName="[email protected]" password="mypassword" />
  </smtp>
</mailSettings>

If someone has a suitable PHP sample, feel free to edit my answer or post your own.

like image 31
Eric J. Avatar answered Oct 22 '22 22:10

Eric J.


Authentication is required I believe, but I don't see why not. I won't do the research for you, but there are a couple things to look into:

  • Their SMTP server requires TLS encryption and is hosted on a non-standard port (995). You will need to ensure that AWS supports both of these options for SMTP outbound.
  • There is probably a cap on emails you can send before being marked as spam. You should research this and ensure it is not beyond your requirements.
like image 34
regex Avatar answered Oct 22 '22 21:10

regex