suntzu Posted January 5, 2007 Share Posted January 5, 2007 Hi to All,I am trying to use gmail as mail server using SMTP = smtp.gmail.com andsmtp_port = 465 in the php.iniI 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 More sharing options...
ikmyer Posted January 5, 2007 Share Posted January 5, 2007 gmail uses secure connections. that might have something to do with it... I found a class awhile back that would send emails using a gmail account. I will look for it and post when i find it Link to comment https://forums.phpfreaks.com/topic/33017-gmail-as-mail-server/#findComment-153778 Share on other sites More sharing options...
ikmyer Posted January 5, 2007 Share Posted January 5, 2007 check out http://www.vulgarisoip.com/?p=17 Link to comment https://forums.phpfreaks.com/topic/33017-gmail-as-mail-server/#findComment-153783 Share on other sites More sharing options...
suntzu Posted January 5, 2007 Author Share Posted January 5, 2007 thank you ikmyer ... let me check it out :) Link to comment https://forums.phpfreaks.com/topic/33017-gmail-as-mail-server/#findComment-153786 Share on other sites More sharing options...
suntzu Posted January 5, 2007 Author Share Posted January 5, 2007 [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 More sharing options...
ikmyer Posted January 6, 2007 Share Posted January 6, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.