XPertMailer Home Page
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Mailing using XPertMailer for Google Apps

 
Post new topic   Reply to topic    XPertMailer Forum Index -> Examples
View previous topic :: View next topic  
Author Message
mailme



Joined: 30 Sep 2007
Posts: 2
Location: 3rd Rock

PostPosted: Sun Sep 30, 2007 6:29 pm    Post subject: Mailing using XPertMailer for Google Apps Reply with quote

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

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
View user's profile Send private message Visit poster's website
arashas



Joined: 22 Sep 2007
Posts: 8

PostPosted: Fri Oct 19, 2007 7:22 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 14 Aug 2007
Posts: 136

PostPosted: Fri Oct 19, 2007 4:03 pm    Post subject: Reply with quote

Read the "EXAMPLES" folder from XPM4 download package, you will find the "mail-relay.php" file for Gmail example.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
brad13x



Joined: 25 Mar 2008
Posts: 1

PostPosted: Tue Mar 25, 2008 5:27 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 14 Aug 2007
Posts: 136

PostPosted: Tue Mar 25, 2008 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
goob



Joined: 11 Apr 2008
Posts: 1

PostPosted: Fri Apr 11, 2008 11:27 am    Post subject: Not working Reply with quote

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
View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 14 Aug 2007
Posts: 136

PostPosted: Sat Apr 12, 2008 1:56 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
miguelguerra



Joined: 01 Jun 2010
Posts: 2
Location: Porto, Portugal

PostPosted: Tue Jun 01, 2010 3:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
miguelguerra



Joined: 01 Jun 2010
Posts: 2
Location: Porto, Portugal

PostPosted: Wed Jun 02, 2010 1:45 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    XPertMailer Forum Index -> Examples All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group