Jump to content

Gmail as mail server ...


suntzu

Recommended Posts

Hi to All,

I am trying to use gmail as mail server using SMTP = smtp.gmail.com and
smtp_port = 465 in the php.ini

I am trying to check this with the following very simple php code but nothing happens.

[code]
<?php
$to = "[email protected]";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$header = "From:[email protected]";
if (mail($to, $subject, $body, $header)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
?>
[/code]

What am i doing wrong?

thnx in advance
Link to comment
https://forums.phpfreaks.com/topic/33017-gmail-as-mail-server/
Share on other sites

[quote author=ikmyer link=topic=121168.msg497719#msg497719 date=1168032292]
check out http://www.vulgarisoip.com/?p=17
[/quote]

Have you tried it by yourself ? I receive an error like this :
Message was not sentMailer Error: Language string failed to load: [email protected]

Do i need to change php.ini in this case or not ?
Link to comment
https://forums.phpfreaks.com/topic/33017-gmail-as-mail-server/#findComment-153826
Share on other sites

no, its all done in that class.  you have to have a gmail account.
Make sure you include the class file in your page.

Put the following in your script where you want to send the mail...
[code]
require_once('/phpgmailer/class.phpgmailer.php');  // path to class.phpgmailer.php on your server
$mail = new PHPGMailer();
$mail->Username = '[email protected]';              // your gmail account
$mail->Password = 'password';                          // your gmail password
$mail->From = '[email protected]';                    //gmail email address
$mail->FromName = 'User Name';                      // a from name
$mail->Subject = 'Subject';                              // subject
$mail->AddAddress('[email protected]');        //email address to send to
$mail->Body = 'Hey buddy, here's an email!';          // message
$mail->Send();                             
[/code]
Link to comment
https://forums.phpfreaks.com/topic/33017-gmail-as-mail-server/#findComment-153927
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.