-
Hi there,
I am trying to send a mail via SMTP and PHPMailer.
The script works fine unless I try to set SMTPSecure to tls. This causes_"SMTP Error: Could not connect to SMTP host. STARTTLS command failed Unrecognized command"
587 is set as port and the outbound relay is looking okay.If someone could point me in a good direction, I would be very thankful :).
Remaining arguments:
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = getenv('CLOUDRON_MAIL_SMTP_SERVER');
$mail->SMTPAuth = true;
$mail->Username = getenv('CLOUDRON_MAIL_SMTP_USERNAME');
$mail->Password = getenv('CLOUDRON_MAIL_SMTP_PASSWORD');
$mail->SMTPSecure = '';
$mail->Port = getenv('CLOUDRON_MAIL_SMTP_PORT');$mail->setFrom(getenv('CLOUDRON_MAIL_FROM'), 'Mailer'); $mail->addReplyTo($email, 'Hello back'); $mail->addAddress('dummymail@dummy.com', 'Cloudron Test'); $mail->Subject = 'Hello World'; $mail->Body = json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); $mail->CharSet = 'UTF-8'; $mail->Encoding = 'base64'; -
J joseph moved this topic from Support on
-
Hi Joseph,
sorry for being unclear here - the mail is being send out if I set $mail->SMTPSecure = ''; like in the example mail at https://docs.cloudron.io/apps/lamp/#email. However, once setting it to $mail->SMTPSecure = 'tls'; I get the error above.
Will $mail->SMTPSecure = ''; use TLS anyways if the outbound relay is configured to do so?
-
Hi Joseph,
sorry for being unclear here - the mail is being send out if I set $mail->SMTPSecure = ''; like in the example mail at https://docs.cloudron.io/apps/lamp/#email. However, once setting it to $mail->SMTPSecure = 'tls'; I get the error above.
Will $mail->SMTPSecure = ''; use TLS anyways if the outbound relay is configured to do so?
@Laktasekampagne said in PHPMailer - SMTP Error: Could not connect to SMTP host. STARTTLS command failed Unrecognized command:
Will $mail->SMTPSecure = ''; use TLS anyways if the outbound relay is configured to do so?
yes, the relay settings are totally different. The PHP code is defining the connection from your app to the cloudron internal mail server . The relay settings is always STARTTLS.
Also, since the internal mail server is running on the same server as the app, the connection is totally internal to the server. $mail->SMTPSecure = '' is safe.
-
Thank you Joseph - that helped a lot. Then, everything just works fine :).
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login