News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Sending Fax by Email - no attachment
Tags: fax
Nov 17, 2022 at 9:46am   •   4 replies  •  0 likes
Holly Opio

We have an internal api that sends faxes directly from our database using php mailer. it sends both email and fax. for internal control purposes we need to continue to use this method rather than a new API just for faxes. It sends the fax / cover page, but does not send the pdf attachment.


PHP:

$fax = "111-222-3333";

$mail = new PHPMailer(true); // Passing `true` enables exceptions

$mail->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false));

$mail->CharSet = 'UTF-8';

$mail->Encoding = "base64";

try {

//Server settings

$mail->isSMTP(); // Set mailer to use SMTP

$mail->Host = 'localhost'; // Specify main and backup SMTP servers

$mail->SMTPSecure = 'tls'; // use TLS

$mail->Port = 587; // TCP port to connect to


$mail->setFrom($faxFrom);

$mail->addReplyTo($faxFrom);


$sFax2 = $fax . "@rcfax.com";

$mail->addAddress($sFax2); // Add a recipient

$mail->addAttachment($tmpfname . "_bcst.pdf", "Home Report"); // Add attachments


//Content

$sSubject = "BROADCAST " . $home->FacilityName . " - " . $client->getStrName() . " - REFID:" . $row->id; // . " - FLID:" . $fl->id;

$mail->Subject = $sSubject;

$mail->Body = " ";

$mail->isHTML(false);


$mail->send();

} catch (Exception $e) {

}

}


peter@middleware:~$ cat /mnt/BinaryData/2022/FL107248.txt

SERVER -> CLIENT: 220 api.ca***nt.com ESMTP Postfix (Ubuntu)

CLIENT -> SERVER: EHLO api.ca***nt.com

SERVER -> CLIENT: 250-api.ca***nt.com

250-PIPELINING

250-SIZE 50000000

250-VRFY

250-ETRN

250-STARTTLS

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250-DSN

250 SMTPUTF8

CLIENT -> SERVER: STARTTLS

SERVER -> CLIENT: 220 2.0.0 Ready to start TLS

CLIENT -> SERVER: EHLO api.ca***nt.com

SERVER -> CLIENT: 250-api.ca***nt.com

250-PIPELINING

250-SIZE 50000000

250-VRFY

250-ETRN

250-AUTH PLAIN LOGIN

250-AUTH=PLAIN LOGIN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250-DSN

250 SMTPUTF8

CLIENT -> SERVER: MAIL FROM:<fax@ca***nt.com>

SERVER -> CLIENT: 250 2.1.0 Ok

CLIENT -> SERVER: RCPT TO:<888-812-6909@rcfax.com>

SERVER -> CLIENT: 250 2.1.5 Ok

CLIENT -> SERVER: DATA

SERVER -> CLIENT: 354 End data with <CR><LF>.<CR><LF>

CLIENT -> SERVER: Date: Fri, 21 Oct 2022 17:12:53 -0700

CLIENT -> SERVER: To: 888-812-6909@rcfax.com

CLIENT -> SERVER: From: fax@ca***nt.com

CLIENT -> SERVER: Reply-To: fax@ca***nt.com

CLIENT -> SERVER: Subject: BROADCAST Sanitized Subject - REFID:146230

CLIENT -> SERVER: Message-ID: <SNwrVIZ66yO9ff6ReAhARR2VGYT86DKoIdNAK9zh0@api.ca***nt.com>

CLIENT -> SERVER: X-Mailer: PHPMailer 6.0.3 (https://github.com/PHPMailer/PHPMailer)

CLIENT -> SERVER: MIME-Version: 1.0

CLIENT -> SERVER: Content-Type: multipart/mixed;

CLIENT -> SERVER: boundary="b1_SNwrVIZ66yO9ff6ReAhARR2VGYT86DKoIdNAK9zh0"

CLIENT -> SERVER:

CLIENT -> SERVER: This is a multi-part message in MIME format.

CLIENT -> SERVER: --b1_SNwrVIZ66yO9ff6ReAhARR2VGYT86DKoIdNAK9zh0

CLIENT -> SERVER: Content-Type: text/plain; charset=UTF-8

CLIENT -> SERVER: Content-Transfer-Encoding: base64

CLIENT -> SERVER:

CLIENT -> SERVER: IA==

CLIENT -> SERVER:

CLIENT -> SERVER: --b1_SNwrVIZ66yO9ff6ReAhARR2VGYT86DKoIdNAK9zh0

CLIENT -> SERVER: Content-Type: application/pdf; name="Home Report"

CLIENT -> SERVER: Content-Transfer-Encoding: base64

CLIENT -> SERVER: Content-ID: <Home Report>

CLIENT -> SERVER: Content-Disposition: attachment; filename="Home Report"

CLIENT -> SERVER:

CLIENT -> SERVER: JVBERi0xLjQKMSAwIG9iago8PAovVGl0bGUgKP7/AEIAcgBvAGEAZABjAGEAcwB0KQovQ3JlYXRv

CLIENT -> SERVER: ciAo/v8AdwBrAGgAdABtAGwAdABvAHAAZABmACAAMAAuADEAMgAuADQpCi9Qcm9kdWNlciAo/v8A

...

CLIENT -> SERVER: MDI1NTQ5IDAwMDAwIG4gCjAwMDAwMzQxODUgMDAwMDAgbiAKMDAwMDAzNDY0MyAwMDAwMCBuIAow

CLIENT -> SERVER: MDAwMDM0MTY0IDAwMDAwIG4gCnRyYWlsZXIKPDwKL1NpemUgMjcKL0luZm8gMSAwIFIKL1Jvb3Qg

CLIENT -> SERVER: MTIgMCBSCj4+CnN0YXJ0eHJlZgozNTcyMQolJUVPRgo=

CLIENT -> SERVER:

CLIENT -> SERVER: --b1_SNwrVIZ66yO9ff6ReAhARR2VGYT86DKoIdNAK9zh0--

CLIENT -> SERVER:

CLIENT -> SERVER: .

SERVER -> CLIENT: 250 2.0.0 Ok: queued as 04268A2017C

CLIENT -> SERVER: QUIT

SERVER -> CLIENT: 221 2.0.0 Bye

peter@middleware:~$


on Nov 24, 2022 at 7:37am   •  0 likes

Can anyone help?
This shouldn't be a sandbox vs production issue, as I am just mimicking the sending of an email. just as I can fax by sending an email to FAX#@rcfax.com from my authorized email, I should be able to send using phpmailer. for some reason RC is not parsing the multipart email the same way that other services do, but I just need to know what RC wants in the email so that I build it correctly

on Nov 24, 2022 at 9:24am   •  0 likes

To be honest, I get dizzy when I look at your codes and traces. I don't see any thing related to RingCentral Fax API. I can just help you if you are using our official Fax API and here is the sample code how to send faxes using PHP language.

https://developers.ringcentral.com/guide/messaging/fax/sending-faxes#php

on Nov 27, 2022 at 5:23pm   •  0 likes

as I mentioned at the beginning, I need to try and keep the 2 fax services as close as possible in how the fax is sent.

You can ignore the trace, I only added it to show the actual email transaction with the email server.

The php code is about as simple as it gets. It sets a few options, sets a TO: and FROM:, adds the PDF and sends it. PHPMailer is simply sending an email to fax#@rcfax.com, however when RC sends the fax it only sends the cover page. I suspect that it has something to do with how the multipart email is being parsed by RC as opposed to FF.

However here is a stripped down version of the Mailer code:

 $mail = new PHPMailer();
 try {
    $mail->setFrom("fax@ca********nt.com");
    $mail->addAddress("1112223333@rcfax.com");
    $mail->addAttachment("report.pdf", "Report"); 
    $mail->Subject = "Fax From Peter";
    $mail->Body = " ";
    $mail->send();
 } catch (Exception $e) { }


on Nov 17, 2022 at 10:16am   •  0 likes

production

on Nov 17, 2022 at 9:54am   •  0 likes

Can you confirm that if this is your test call on the sandbox environment or on your production environment?

1 Answer
answered on Dec 20, 2022 at 10:13am  

Change $mail->addAttachment("report.pdf", "Report");

to $mail->addAttachment("report.pdf", "report.pdf");

And try again.

Make sure you always specify the file extension .

PS. The solution was figured out by my colleague Kirill Tikhonov.


 0
on Dec 20, 2022 at 11:44am   •  0 likes

Thank you very much that resolved it. Our last solution didn't require the extension and allowed us to use a screen friendly name.

answered on Nov 17, 2022 at 10:15am  

production


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us