| View previous topic :: View next topic |
| Author |
Message |
mailme
Joined: 30 Sep 2007 Posts: 2 Location: 3rd Rock
|
Posted: Sun Sep 30, 2007 6:29 pm Post subject: Mailing using XPertMailer for Google Apps |
|
|
Even though the documentation is clear on sending email using tls I thought this would be helpful for those lazy souls out there using google apps for their domain.
So if you are looking for an easy way to implement email on your server using php and sent from a Google Mail domain here is the solution.
Enjoy.
| Code: | <?php
define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
require_once './SMTP.php'; // path to 'SMTP.php' file from XPM4 package
$f = 'someaddress@yourdomain.com'; // from mail address
$t = 'someaddress@gmail.com'; // to mail address
// standard mail message RFC2822
$m = 'From: '.$f."\r\n".
'To: '.$t."\r\n".
'Subject: XPertMailer Generated Notification'."\r\n".
'Content-Type: text/plain'."\r\n\r\n".
'This email was autogenerated by a script on your server!';
$h = 'smtp.gmail.com';
$port = 465;
$user = 'someaddress@yourdomain.com';
$pwd = 'apassword';
$auth_type = 'tls';
$timeout = 10;
$c = SMTP::connect($h,$port,$user,$pwd,$auth_type,$timeout);
$s = SMTP::Send($c, array($t), $m, $f); // send mail
// print result
if ($s) echo 'Sent !';
else print_r($_RESULT);
SMTP::Disconnect($c); // disconnect
?>
|
|
|
| Back to top |
|
 |
arashas
Joined: 22 Sep 2007 Posts: 8
|
Posted: Fri Oct 19, 2007 7:22 am Post subject: |
|
|
I did the same but I just get a blank page
my code is
| Code: |
<?php
define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors
require_once '/SMTP.php'; // path to 'SMTP.php' file from XPM4 package
$f = 'testa@mydomain.com'; // from mail address
$t = 'membership@mydomain.com'; // to mail address
// standard mail message RFC2822
$m = 'From: '.$f."\r\n".
'To: '.$t."\r\n".
'Subject: XPertMailer Generated Notification'."\r\n".
'Content-Type: text/plain'."\r\n\r\n".
'This email was autogenerated by a script on your server!';
$h = 'smtp.gmail.com';
$port = 465;
$user = 'testa@mydomain.com';
$pwd = 'asdasd';
$auth_type = 'tls';
$timeout = 10;
$c = SMTP::connect($h,$port,$user,$pwd,$auth_type,$timeout);
$s = SMTP::Send($c, array($t), $m, $f); // send mail
// print result
if ($s) echo 'Sent !';
else print_r($_RESULT);
SMTP::Disconnect($c); // disconnect
?>
|
what is your Idea?
Last edited by arashas on Wed Dec 19, 2007 1:12 am; edited 1 time in total |
|
| Back to top |
|
 |
admin Site Admin
Joined: 14 Aug 2007 Posts: 136
|
Posted: Fri Oct 19, 2007 4:03 pm Post subject: |
|
|
| Read the "EXAMPLES" folder from XPM4 download package, you will find the "mail-relay.php" file for Gmail example. |
|
| Back to top |
|
 |
brad13x
Joined: 25 Mar 2008 Posts: 1
|
Posted: Tue Mar 25, 2008 5:27 pm Post subject: |
|
|
I'm using the mail-relay.php example with my gmail info and the only error i get is
Array ( [301] => Send QUIT ) 1 _________________ XPertMailer - Advanced Mail Engine |
|
| Back to top |
|
 |
admin Site Admin
Joined: 14 Aug 2007 Posts: 136
|
Posted: Tue Mar 25, 2008 7:44 pm Post subject: |
|
|
That's OK, is not a problem, your mail has been sent.
This is the result from disconnect() function and is not an error, is a response code & message customize by XPM4.
| Code: | if (!fwrite($conn, 'QUIT'.self::CRLF)) $_RESULT[300] = 'can not write';
else $_RESULT[301] = 'Send QUIT';
return @fclose($conn); |
_________________
 |
|
| Back to top |
|
 |
goob
Joined: 11 Apr 2008 Posts: 1
|
Posted: Fri Apr 11, 2008 11:27 am Post subject: Not working |
|
|
I have used both the code in this post and the code of the mail_rely.php in EXAMPLES folder, and all I get is:
| Code: | Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to tls://smtp.gmail.com:465 (Connection refused) in /homepages/32/d238394983/htdocs/mail/PHP5/SMTP5.php on line 129
Array ( [101] => Connection refused ) 1 |
¿Can anyone help me? Thank you in advanced. _________________ XPertMailer - Advanced Mail Engine |
|
| Back to top |
|
 |
admin Site Admin
Joined: 14 Aug 2007 Posts: 136
|
Posted: Sat Apr 12, 2008 1:56 pm Post subject: |
|
|
Like the error says you can't connect to smtp.gmail.com at port 465. Check your hosting / internet service provider or firewall / anti-virus software blocking things. You can also try to connect using telnet, command line: "telnet smtp.gmail.com 465". _________________
 |
|
| Back to top |
|
 |
miguelguerra
Joined: 01 Jun 2010 Posts: 2 Location: Porto, Portugal
|
Posted: Tue Jun 01, 2010 3:35 pm Post subject: |
|
|
Hi,
I try this example in my localhost server and it works fine!
But when I try in the production server, can´t send mail and I get this message:
Error: invalid resource connection on SMTP5::send() in /home/aboutfac/public_html/site/paginas/registo.php on line 165
Can anybody help?
Thanks. _________________ XPertMailer - Advanced Mail Engine |
|
| Back to top |
|
 |
miguelguerra
Joined: 01 Jun 2010 Posts: 2 Location: Porto, Portugal
|
Posted: Wed Jun 02, 2010 1:45 pm Post subject: |
|
|
I found the problem.
It was a missing MX Entry in the server for Google Mail.
Thanks anyway. _________________ XPertMailer - Advanced Mail Engine |
|
| Back to top |
|
 |
|