Hi, I try to use this script to send email with gmail using php. <?php // example on using PHPMailer with GMAIL include("class.phpmailer.php"); include("class.smtp.php"); $mail=new PHPMailer(); $mail->IsSMTP(); $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port $mail->Username = "yourname@gmail.com"; // GMAIL username $mail->Password = "password"; // GMAIL password $mail->From = "replyto@yourdomain.com"; $mail->FromName = "Webmaster"; $mail->Subject = "This is the subject"; $mail->Body = "Hi,<br>This is the HTML BODY<br>"; //HTML Body $mail->AltBody = "This is the body when user views in plain text format"; //Text Body $mail->WordWrap = 50; // set word wrap $mail->AddAddress("username@domain.com","First Last"); $mail->AddReplyTo("replyto@yourdomain.com","Webmaster"); $mail->AddAttachment("/path/to/file.zip"); // attachment $mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment $mail->IsHTML(true); // send as HTML if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message has been sent"; } PHP: When I hit submit somehow I get this error: Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) in /home/myname/public_html/jooml/temp/class.smtp.php on line 122 Code (markup): Anyone know what error this is?? or where did I do wrong Any help is apreaciated. Thanks in advance.
Try $mail->Host = 'ssl://smtp.gmail.com:465'; PHP: Instead of $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server PHP:
I change it and now I'm getting two error Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/myname/public_html/jooml/temp/class.smtp.php on line 122 Code (markup): Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://ssl://smtp.gmail.com:465 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/myname/public_html/jooml/temp/class.smtp.php on line 122 Code (markup): Thanks in advance...
The last error I am sure is because of the ssl:// has been repeated somwhere in the code, so find it out and remove it .
Gmail need to use SSL as far as I know... http://mail.google.com/support/bin/answer.py?hl=en&answer=78775 Thanks
Hi agent smith, After using your code I think I still get the same error... Warning: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.gmail.com:465 (Connection timed out) in /home/myname/public_html/jooml/temp/class.smtp.php on line 122 Code (markup): Thanks in advance
Having a random stab here.. Is fsockopen() enabled? http://www.freewebspace.net/forums/showthread.php?t=2200081
LOL after running this script <?php if( function_exists( 'fsockopen' ) ) { if( ( $sock = fsockopen( 'freewebspace.net', 80, $errno, $errstr ) ) ) { printf( "Your client is stupid, fsockopen is available and works<Br />\n" ); } else printf( "Cannot use file descriptor on socket: #%d: %s<br/>\n", $errno, $errstr ); } else printf( "No fsockopen, please post php.ini on fws for joe to look at<br />\n" ); ?> PHP: I'm getting this>> Your client is stupid, fsockopen is available and works Code (markup): So fsockopen is enable then... now what...?? Thanks in advance