Just can't get it to work with Gmail
Posted: Fri Apr 11, 2008 9:03 pm
Hello. I am a total newbie at this, but from what I have read, this is a great piece of software.
I have been having trouble getting it to work for my gmail smtp. At first I tried the smoke tests using that same Gmail SMTP and they all work fine; however when I try to enable it on my server it just won't work. Sometimes it says it can't connect, then I move something around and I get a different error. I spent the whole afternoon reading the forums and the docs trying to find the different problems that might be arising and I can't seem to find and answer.
I am using google apps for my domain. Gmail works great and, as I mentioned earlier, the SMTP smoke tests went out perfect.
Here is what I a trying to do: I set up a website for my practice (I am a physician, which explains my problems with php!) in which the patients request a free consultation. The form validation is working fine and I already have all the resulting strings in variables, but I need to send three separate emails. One to the patient for feedback so he/she knows that we received his/her request, one for my secretary, which includes all information, so she can call and set the appointment, and the third one, containing all the information as well, for me so I can keep track of how many people are requesting consults.
Now, I have not been able to send even the first of those three emails!! I would really appreciate your help. I am running PHP 5.2.5 and swift 3.3.2 for php5
This is the whole code for swift that I have so far.
As I am completing the site, I am uploading to an alternate server, so you can currently check out the form I am trying to send at http://www.freyja.org.mx/cita2.php
Any help will be greatly appreciated. Thank you.
I have been having trouble getting it to work for my gmail smtp. At first I tried the smoke tests using that same Gmail SMTP and they all work fine; however when I try to enable it on my server it just won't work. Sometimes it says it can't connect, then I move something around and I get a different error. I spent the whole afternoon reading the forums and the docs trying to find the different problems that might be arising and I can't seem to find and answer.
I am using google apps for my domain. Gmail works great and, as I mentioned earlier, the SMTP smoke tests went out perfect.
Here is what I a trying to do: I set up a website for my practice (I am a physician, which explains my problems with php!) in which the patients request a free consultation. The form validation is working fine and I already have all the resulting strings in variables, but I need to send three separate emails. One to the patient for feedback so he/she knows that we received his/her request, one for my secretary, which includes all information, so she can call and set the appointment, and the third one, containing all the information as well, for me so I can keep track of how many people are requesting consults.
Now, I have not been able to send even the first of those three emails!! I would really appreciate your help. I am running PHP 5.2.5 and swift 3.3.2 for php5
This is the whole code for swift that I have so far.
Code: Select all
// Al haber pasado la validación, inicia Swift
require_once "swift/Swift.php";
require_once "swift/Swift/Connection/SMTP.php";
require_once "swift/Swift/Authenticator/LOGIN.php";
// Iniciar sesión en el SMTP
$smtp = new Swift_Connection_SMTP("smtp.gmail.com", SWIFT_SMTP_PORT_SECURE, ENC_TLS);
$smtp->setUsername("myemail@freyja.com.mx");
$smtp->setPassword("password");
$conn =& new Swift_Connection_SMTP("smtp.gmail.com");
$conn->attachAuthenticator(new Swift_Authenticator_LOGIN());
$swift = new Swift(new Swift_Connection_SMTP("smtp.gmail.com", Swift_Connection_SMTP::PORT_SECURE, Swift_Connection_SMTP::ENC_TLS));
//Crear el mensaje a enviar
$body = "¡Hola $nombre!<br><br>Hemos recibido tu solicitud para una cita en el área de $area_cita. Mencionaste que te podemos hablar $dia_contacto a las $horario_contacto.<br><br> Si tienes cualquier duda al respecto, no dudes en ponerte en contacto con nosotros al 5253.26.85 ó en la dirección de correo info@freyja.com.mx.<br><br>No respondas directamente a este correo ya que no tenemos manera de recibir el mensaje.<br><br>!Que tengas un buen día!";
$sender = new Swift_Address($email, $nombre);
$message = new Swift_Message("Solicitud de cita en: " . $area_cita);
$message->attach(new Swift_Message_Part($body));
//Try sending the email
$sent = $swift->send($message, "citas@freyja.com.mx", $sender);
//Disconnect from SMTP, we're done
$swift->disconnect();Any help will be greatly appreciated. Thank you.